home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1992-08-19 | 459.0 KB | [ ONLN/HLX2]
open in: MacOS 8.1
extracted
|
Win98
extracted
|
DOS
extracted
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary ).
Confidence Program Detection Match Type Support
10%
dexvert
MacBinary (archive/macBinary)
fallback
Supported
100%
file
MacBinary II, inited, Sun Jul 19 07:45:01 1992, modified Tue Aug 18 22:38:49 1992, creator 'HLX2', type 'ONLN', 459883 bytes "The Asynchronous Sound Helper" , at 0x704eb 9909 bytes resource
default (weak)
99%
file
data
default
100%
TrID
MacBinary 2
default (weak)
100%
siegfried
fmt/1762 MacBinary (II)
default
100%
lsar
MacBinary
default
id metadata key value macFileType [ ONLN] macFileCreator [ HLX2]
hex view +--------+-------------------------+-------------------------+--------+--------+ |00000000| 00 1d 54 68 65 20 41 73 | 79 6e 63 68 72 6f 6e 6f |..The As|ynchrono| |00000010| 75 73 20 53 6f 75 6e 64 | 20 48 65 6c 70 65 72 00 |us Sound| Helper.| |00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........| |00000040| 00 4f 4e 4c 4e 48 4c 58 | 32 01 00 00 00 00 00 00 |.ONLNHLX|2.......| |00000050| 00 00 00 00 07 04 6b 00 | 00 26 b5 a6 8f 06 3d a6 |......k.|.&....=.| |00000060| b7 64 b9 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.d......|........| |00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 7b cd 00 00 |........|....{...| |00000080| 54 48 45 20 41 53 59 4e | 43 48 52 4f 4e 4f 55 53 |THE ASYN|CHRONOUS| |00000090| 20 53 4f 55 4e 44 20 48 | 45 4c 50 45 52 0d 42 52 | SOUND H|ELPER.BR| |000000a0| 59 41 4e 20 4b 2e 20 28 | d3 42 45 41 4b 45 52 d3 |YAN K. (|.BEAKER.| |000000b0| 29 20 52 45 53 53 4c 45 | 52 0d 49 6e 20 73 79 73 |) RESSLE|R.In sys| |000000c0| 74 65 6d 20 73 6f 66 74 | 77 61 72 65 20 76 65 72 |tem soft|ware ver| |000000d0| 73 69 6f 6e 20 36 2e 30 | 2e 37 20 61 6e 64 20 6c |sion 6.0|.7 and l| |000000e0| 61 74 65 72 2c 20 74 68 | 65 20 53 6f 75 6e 64 20 |ater, th|e Sound | |000000f0| 4d 61 6e 61 67 65 72 20 | 68 61 73 20 69 6d 70 72 |Manager |has impr| |00000100| 65 73 73 69 76 65 20 73 | 6f 75 6e 64 20 69 6e 70 |essive s|ound inp| |00000110| 75 74 20 61 6e 64 20 6f | 75 74 70 75 74 20 63 61 |ut and o|utput ca| |00000120| 70 61 62 69 6c 69 74 69 | 65 73 20 74 68 61 74 20 |pabiliti|es that | |00000130| 61 72 65 20 6c 61 72 67 | 65 6c 79 20 75 6e 74 61 |are larg|ely unta| |00000140| 70 70 65 64 20 62 79 20 | 74 68 65 20 65 78 69 73 |pped by |the exis| |00000150| 74 69 6e 67 20 62 6f 64 | 79 20 6f 66 20 61 70 70 |ting bod|y of app| |00000160| 6c 69 63 61 74 69 6f 6e | 20 73 6f 66 74 77 61 72 |lication| softwar| |00000170| 65 2e 20 54 68 69 73 20 | 61 72 74 69 63 6c 65 20 |e. This |article | |00000180| 70 72 65 73 65 6e 74 73 | 20 61 20 63 6f 64 65 20 |presents| a code | |00000190| 6d 6f 64 75 6c 65 20 63 | 61 6c 6c 65 64 20 74 68 |module c|alled th| |000001a0| 65 20 41 73 79 6e 63 68 | 72 6f 6e 6f 75 73 20 53 |e Asynch|ronous S| |000001b0| 6f 75 6e 64 20 48 65 6c | 70 65 72 20 74 68 61 74 |ound Hel|per that| |000001c0| d5 73 20 64 65 73 69 67 | 6e 65 64 20 74 6f 20 6d |.s desig|ned to m| |000001d0| 61 6b 65 20 61 73 79 6e | 63 68 72 6f 6e 6f 75 73 |ake asyn|chronous| |000001e0| 20 73 6f 75 6e 64 20 69 | 6e 70 75 74 20 61 6e 64 | sound i|nput and| |000001f0| 20 6f 75 74 70 75 74 20 | 65 61 73 69 6c 79 20 61 | output |easily a| |00000200| 63 63 65 73 73 69 62 6c | 65 20 74 6f 20 74 68 65 |ccessibl|e to the| |00000210| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 70 72 6f | applica|tion pro| |00000220| 67 72 61 6d 6d 65 72 2c | 20 79 65 74 20 70 72 6f |grammer,| yet pro| |00000230| 76 69 64 65 20 61 6e 20 | 69 6e 74 65 72 66 61 63 |vide an |interfac| |00000240| 65 20 66 6c 65 78 69 62 | 6c 65 20 65 6e 6f 75 67 |e flexib|le enoug| |00000250| 68 20 74 6f 20 66 61 63 | 69 6c 69 74 61 74 65 20 |h to fac|ilitate | |00000260| 65 78 74 65 6e 73 69 76 | 65 20 61 70 70 6c 69 63 |extensiv|e applic| |00000270| 61 74 69 6f 6e 20 66 65 | 61 74 75 72 65 73 2e 0d |ation fe|atures..| |00000280| 4f 66 20 61 6c 6c 20 74 | 68 65 20 4d 61 6e 61 67 |Of all t|he Manag| |00000290| 65 72 73 20 69 6e 20 49 | 6e 73 69 64 65 20 4d 61 |ers in I|nside Ma| |000002a0| 63 69 6e 74 6f 73 68 2c | 20 74 68 65 20 53 6f 75 |cintosh,| the Sou| |000002b0| 6e 64 20 4d 61 6e 61 67 | 65 72 20 6d 61 79 20 62 |nd Manag|er may b| |000002c0| 65 20 74 68 65 20 77 69 | 6e 6e 65 72 20 6f 66 20 |e the wi|nner of | |000002d0| 74 68 65 20 4d 6f 73 74 | 20 53 74 61 72 74 6c 69 |the Most| Startli| |000002e0| 6e 67 20 4d 65 74 61 6d | 6f 72 70 68 6f 73 69 73 |ng Metam|orphosis| |000002f0| 20 63 6f 6e 74 65 73 74 | 2e 20 4f 6e 20 74 68 65 | contest|. On the| |00000300| 20 65 61 72 6c 69 65 73 | 74 20 4d 61 63 69 6e 74 | earlies|t Macint| |00000310| 6f 73 68 20 63 6f 6d 70 | 75 74 65 72 73 2c 20 73 |osh comp|uters, s| |00000320| 6f 75 6e 64 20 77 61 73 | 20 70 72 6f 64 75 63 65 |ound was| produce| |00000330| 64 20 62 79 20 64 69 72 | 65 63 74 20 63 61 6c 6c |d by dir|ect call| |00000340| 73 20 74 6f 20 61 20 53 | 6f 75 6e 64 20 44 72 69 |s to a S|ound Dri| |00000350| 76 65 72 2c 20 61 73 20 | 64 65 73 63 72 69 62 65 |ver, as |describe| |00000360| 64 20 69 6e 20 49 6e 73 | 69 64 65 20 4d 61 63 69 |d in Ins|ide Maci| |00000370| 6e 74 6f 73 68 20 56 6f | 6c 75 6d 65 20 49 49 2e |ntosh Vo|lume II.| |00000380| 20 4c 61 74 65 72 2c 20 | 77 69 74 68 20 74 68 65 | Later, |with the| |00000390| 20 61 64 76 65 6e 74 20 | 6f 66 20 73 79 73 74 65 | advent |of syste| |000003a0| 6d 20 73 6f 66 74 77 61 | 72 65 20 76 65 72 73 69 |m softwa|re versi| |000003b0| 6f 6e 20 34 2e 31 20 61 | 6e 64 20 74 68 65 20 6d |on 4.1 a|nd the m| |000003c0| 6f 72 65 20 70 6f 77 65 | 72 66 75 6c 20 73 6f 75 |ore powe|rful sou| |000003d0| 6e 64 2d 67 65 6e 65 72 | 61 74 69 6f 6e 20 68 61 |nd-gener|ation ha| |000003e0| 72 64 77 61 72 65 20 6f | 66 20 74 68 65 20 4d 61 |rdware o|f the Ma| |000003f0| 63 69 6e 74 6f 73 68 20 | 53 45 20 61 6e 64 20 4d |cintosh |SE and M| |00000400| 61 63 69 6e 74 6f 73 68 | 20 49 49 2c 20 74 68 65 |acintosh| II, the| |00000410| 20 53 6f 75 6e 64 20 44 | 72 69 76 65 72 20 77 61 | Sound D|river wa| |00000420| 73 20 73 75 70 65 72 73 | 65 64 65 64 20 62 79 20 |s supers|eded by | |00000430| 61 20 66 61 69 72 6c 79 | 20 62 75 67 67 79 20 69 |a fairly| buggy i| |00000440| 6e 69 74 69 61 6c 20 69 | 6d 70 6c 65 6d 65 6e 74 |nitial i|mplement| |00000450| 61 74 69 6f 6e 20 6f 66 | 20 74 68 65 20 53 6f 75 |ation of| the Sou| |00000460| 6e 64 20 4d 61 6e 61 67 | 65 72 2c 20 77 68 69 63 |nd Manag|er, whic| |00000470| 68 20 77 61 73 20 66 69 | 72 73 74 20 64 6f 63 75 |h was fi|rst docu| |00000480| 6d 65 6e 74 65 64 20 69 | 6e 20 49 6e 73 69 64 65 |mented i|n Inside| |00000490| 20 4d 61 63 69 6e 74 6f | 73 68 20 56 6f 6c 75 6d | Macinto|sh Volum| |000004a0| 65 20 56 2e 20 54 68 65 | 20 6e 65 77 20 53 6f 75 |e V. The| new Sou| |000004b0| 6e 64 20 4d 61 6e 61 67 | 65 72 20 70 72 65 73 65 |nd Manag|er prese| |000004c0| 6e 74 65 64 20 61 20 70 | 72 6f 62 6c 65 6d 20 66 |nted a p|roblem f| |000004d0| 6f 72 20 64 65 76 65 6c | 6f 70 65 72 73 2c 20 62 |or devel|opers, b| |000004e0| 65 63 61 75 73 65 20 74 | 68 65 72 65 20 77 61 73 |ecause t|here was| |000004f0| 20 61 20 6c 61 72 67 65 | 20 69 6e 73 74 61 6c 6c | a large| install| |00000500| 65 64 20 62 61 73 65 20 | 6f 66 20 4d 61 63 69 6e |ed base |of Macin| |00000510| 74 6f 73 68 20 31 32 38 | 4b 2c 20 35 31 32 4b 2c |tosh 128|K, 512K,| |00000520| 20 35 31 32 4b 20 65 6e | 68 61 6e 63 65 64 2c 20 | 512K en|hanced, | |00000530| 61 6e 64 20 50 6c 75 73 | 20 63 6f 6d 70 75 74 65 |and Plus| compute| |00000540| 72 73 20 74 68 61 74 20 | 64 69 64 6e d5 74 20 68 |rs that |didn.t h| |00000550| 61 76 65 20 74 68 65 20 | 52 4f 4d 73 20 6f 72 20 |ave the |ROMs or | |00000560| 73 79 73 74 65 6d 20 73 | 6f 66 74 77 61 72 65 20 |system s|oftware | |00000570| 74 6f 20 73 75 70 70 6f | 72 74 20 74 68 65 20 53 |to suppo|rt the S| |00000580| 6f 75 6e 64 20 4d 61 6e | 61 67 65 72 2e 20 41 74 |ound Man|ager. At| |00000590| 20 74 68 69 73 20 70 6f | 69 6e 74 2c 20 61 6c 6c | this po|int, all| |000005a0| 20 62 75 74 20 74 68 65 | 20 68 65 61 72 74 69 65 | but the| heartie| |000005b0| 73 74 20 64 65 76 65 6c | 6f 70 65 72 73 20 64 65 |st devel|opers de| |000005c0| 63 69 64 65 64 20 74 68 | 65 20 74 72 61 64 65 6f |cided th|e tradeo| |000005d0| 66 66 73 20 66 6f 72 20 | 69 6e 63 6c 75 64 69 6e |ffs for |includin| |000005e0| 67 20 73 6f 75 6e 64 20 | 69 6e 20 61 20 6e 6f 6e |g sound |in a non| |000005f0| d0 73 6f 75 6e 64 2d 72 | 65 6c 61 74 65 64 20 61 |.sound-r|elated a| |00000600| 70 70 6c 69 63 61 74 69 | 6f 6e 20 77 65 72 65 20 |pplicati|on were | |00000610| 74 6f 6f 20 73 65 76 65 | 72 65 2e 0d 42 79 20 74 |too seve|re..By t| |00000620| 68 65 20 74 69 6d 65 20 | 76 65 72 73 69 6f 6e 20 |he time |version | |00000630| 36 2e 30 2e 37 20 72 6f | 6c 6c 65 64 20 61 72 6f |6.0.7 ro|lled aro| |00000640| 75 6e 64 2c 20 6d 61 6e | 79 20 6f 66 20 74 68 65 |und, man|y of the| |00000650| 20 64 65 74 61 69 6c 73 | 20 6f 66 20 74 68 65 20 | details| of the | |00000660| 53 6f 75 6e 64 20 4d 61 | 6e 61 67 65 72 20 68 61 |Sound Ma|nager ha| |00000670| 64 20 63 68 61 6e 67 65 | 64 2c 20 61 6e 64 20 73 |d change|d, and s| |00000680| 6f 75 6e 64 20 69 6e 70 | 75 74 20 73 75 70 70 6f |ound inp|ut suppo| |00000690| 72 74 20 77 61 73 20 61 | 64 64 65 64 2e 20 49 6e |rt was a|dded. In| |000006a0| 20 66 61 63 74 2c 20 74 | 68 65 20 53 6f 75 6e 64 | fact, t|he Sound| |000006b0| 20 4d 61 6e 61 67 65 72 | 20 69 6e 20 36 2e 30 2e | Manager| in 6.0.| |000006c0| 37 20 61 6e 64 20 53 79 | 73 74 65 6d 20 37 20 69 |7 and Sy|stem 7 i| |000006d0| 73 20 72 65 6c 61 74 69 | 76 65 6c 79 20 73 74 61 |s relati|vely sta| |000006e0| 62 6c 65 2e 20 53 6f 20 | 69 66 20 79 6f 75 d5 76 |ble. So |if you.v| |000006f0| 65 20 62 65 65 6e 20 77 | 61 69 74 69 6e 67 20 66 |e been w|aiting f| |00000700| 6f 72 20 74 68 65 20 72 | 69 67 68 74 20 6d 6f 6d |or the r|ight mom| |00000710| 65 6e 74 20 74 6f 20 61 | 64 64 20 73 6f 75 6e 64 |ent to a|dd sound| |00000720| 20 73 75 70 70 6f 72 74 | 20 74 6f 20 79 6f 75 72 | support| to your| |00000730| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 2c 20 74 68 | applica|tion, th| |00000740| 65 20 6d 6f 6d 65 6e 74 | 20 68 61 73 20 61 72 72 |e moment| has arr| |00000750| 69 76 65 64 2e 0d 54 68 | 65 20 4d 61 63 69 6e 74 |ived..Th|e Macint| |00000760| 6f 73 68 20 53 6f 75 6e | 64 20 4d 61 6e 61 67 65 |osh Soun|d Manage| |00000770| 72 20 61 63 74 73 20 61 | 73 20 61 20 62 75 66 66 |r acts a|s a buff| |00000780| 65 72 20 62 65 74 77 65 | 65 6e 20 79 6f 75 72 20 |er betwe|en your | |00000790| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 61 6e 64 20 |applicat|ion and | |000007a0| 74 68 65 20 63 6f 6d 70 | 6c 65 78 69 74 69 65 73 |the comp|lexities| |000007b0| 20 6f 66 20 74 68 65 20 | 73 6f 75 6e 64 20 68 61 | of the |sound ha| |000007c0| 72 64 77 61 72 65 20 28 | 73 65 65 20 46 69 67 75 |rdware (|see Figu| |000007d0| 72 65 20 31 29 2e 20 53 | 6f 75 6e 64 73 20 61 72 |re 1). S|ounds ar| |000007e0| 65 20 70 72 6f 64 75 63 | 65 64 20 62 79 20 73 65 |e produc|ed by se| |000007f0| 6e 64 69 6e 67 20 73 6f | 75 6e 64 20 63 6f 6d 6d |nding so|und comm| |00000800| 61 6e 64 73 20 74 6f 20 | 61 20 73 6f 75 6e 64 20 |ands to |a sound | |00000810| 63 68 61 6e 6e 65 6c 2e | 20 54 68 65 20 73 6f 75 |channel.| The sou| |00000820| 6e 64 20 63 68 61 6e 6e | 65 6c 20 73 65 6e 64 73 |nd chann|el sends| |00000830| 20 74 68 65 20 63 6f 6d | 6d 61 6e 64 73 20 74 68 | the com|mands th| |00000840| 72 6f 75 67 68 20 61 20 | 73 79 6e 74 68 65 73 69 |rough a |synthesi| |00000850| 7a 65 72 20 74 68 61 74 | 20 6b 6e 6f 77 73 20 68 |zer that| knows h| |00000860| 6f 77 20 74 6f 20 63 6f | 6e 74 72 6f 6c 20 74 68 |ow to co|ntrol th| |00000870| 65 20 61 75 64 69 6f 20 | 68 61 72 64 77 61 72 65 |e audio |hardware| |00000880| 2e 20 41 6d 6f 6e 67 20 | 74 68 65 20 53 6f 75 6e |. Among |the Soun| |00000890| 64 20 4d 61 6e 61 67 65 | 72 d5 73 20 63 75 72 72 |d Manage|r.s curr| |000008a0| 65 6e 74 20 33 38 20 63 | 6f 6d 6d 61 6e 64 73 20 |ent 38 c|ommands | |000008b0| 61 72 65 20 6f 70 65 72 | 61 74 69 6f 6e 73 20 73 |are oper|ations s| |000008c0| 75 63 68 20 61 73 20 70 | 6c 61 79 69 6e 67 20 73 |uch as p|laying s| |000008d0| 69 6d 70 6c 65 20 66 72 | 65 71 75 65 6e 63 69 65 |imple fr|equencie| |000008e0| 73 2c 20 0d 70 6c 61 79 | 69 6e 67 20 63 6f 6d 70 |s, .play|ing comp| |000008f0| 6c 65 78 20 72 65 63 6f | 72 64 65 64 20 73 6f 75 |lex reco|rded sou| |00000900| 6e 64 73 2c 20 61 6e 64 | 20 63 68 61 6e 67 69 6e |nds, and| changin| |00000910| 67 20 73 6f 75 6e 64 20 | 76 6f 6c 75 6d 65 2e 20 |g sound |volume. | |00000920| 54 68 65 20 53 6f 75 6e | 64 20 4d 61 6e 61 67 65 |The Soun|d Manage| |00000930| 72 20 61 6c 73 6f 20 61 | 6c 6c 6f 77 73 20 79 6f |r also a|llows yo| |00000940| 75 20 74 6f 20 72 65 63 | 6f 72 64 20 6e 65 77 20 |u to rec|ord new | |00000950| 73 6f 75 6e 64 73 20 69 | 66 20 74 68 65 20 61 70 |sounds i|f the ap| |00000960| 70 72 6f 70 72 69 61 74 | 65 20 68 61 72 64 77 61 |propriat|e hardwa| |00000970| 72 65 20 69 73 20 61 76 | 61 69 6c 61 62 6c 65 2e |re is av|ailable.| |00000980| 20 52 65 63 6f 72 64 69 | 6e 67 20 69 73 20 70 65 | Recordi|ng is pe| |00000990| 72 66 6f 72 6d 65 64 20 | 74 68 72 6f 75 67 68 20 |rformed |through | |000009a0| 61 20 73 6f 75 6e 64 20 | 69 6e 70 75 74 20 64 72 |a sound |input dr| |000009b0| 69 76 65 72 2e 0d 09 0d | 09 0d 46 69 67 75 72 65 |iver....|..Figure| |000009c0| 20 31 0d 54 68 65 20 53 | 6f 75 6e 64 20 4d 61 6e | 1.The S|ound Man| |000009d0| 61 67 65 72 0d 53 6f 75 | 6e 64 20 70 6c 61 79 62 |ager.Sou|nd playb| |000009e0| 61 63 6b 20 61 6e 64 20 | 72 65 63 6f 72 64 69 6e |ack and |recordin| |000009f0| 67 20 74 68 72 6f 75 67 | 68 20 74 68 65 20 53 6f |g throug|h the So| |00000a00| 75 6e 64 20 4d 61 6e 61 | 67 65 72 20 63 61 6e 20 |und Mana|ger can | |00000a10| 62 65 20 70 65 72 66 6f | 72 6d 65 64 20 73 79 6e |be perfo|rmed syn| |00000a20| 63 68 72 6f 6e 6f 75 73 | 6c 79 20 6f 72 20 61 73 |chronous|ly or as| |00000a30| 79 6e 63 68 72 6f 6e 6f | 75 73 6c 79 2e 20 57 68 |ynchrono|usly. Wh| |00000a40| 65 6e 20 79 6f 75 20 6d | 61 6b 65 20 61 20 73 79 |en you m|ake a sy| |00000a50| 6e 63 68 72 6f 6e 6f 75 | 73 20 63 61 6c 6c 20 74 |nchronou|s call t| |00000a60| 6f 20 74 68 65 20 53 6f | 75 6e 64 20 4d 61 6e 61 |o the So|und Mana| |00000a70| 67 65 72 2c 20 74 68 65 | 20 66 75 6e 63 74 69 6f |ger, the| functio| |00000a80| 6e 20 64 6f 65 73 6e d5 | 74 20 72 65 74 75 72 6e |n doesn.|t return| |00000a90| 20 63 6f 6e 74 72 6f 6c | 20 74 6f 20 79 6f 75 72 | control| to your| |00000aa0| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 75 6e 74 | applica|tion unt| |00000ab0| 69 6c 20 74 68 65 20 65 | 6e 74 69 72 65 20 6f 70 |il the e|ntire op| |00000ac0| 65 72 61 74 69 6f 6e 20 | 28 73 6f 75 6e 64 20 70 |eration |(sound p| |00000ad0| 6c 61 79 62 61 63 6b 2c | 20 66 6f 72 20 69 6e 73 |layback,| for ins| |00000ae0| 74 61 6e 63 65 29 20 69 | 73 20 63 6f 6d 70 6c 65 |tance) i|s comple| |00000af0| 74 65 2e 20 49 6e 20 67 | 65 6e 65 72 61 6c 2c 20 |te. In g|eneral, | |00000b00| 69 74 d5 73 20 65 61 73 | 79 20 74 6f 20 75 73 65 |it.s eas|y to use| |00000b10| 20 74 68 65 20 53 6f 75 | 6e 64 20 4d 61 6e 61 67 | the Sou|nd Manag| |00000b20| 65 72 20 74 6f 20 70 6c | 61 79 20 6f 72 20 72 65 |er to pl|ay or re| |00000b30| 63 6f 72 64 20 73 6f 75 | 6e 64 20 73 79 6e 63 68 |cord sou|nd synch| |00000b40| 72 6f 6e 6f 75 73 6c 79 | 2e 20 41 73 79 6e 63 68 |ronously|. Asynch| |00000b50| 72 6f 6e 6f 75 73 20 63 | 61 6c 6c 73 20 72 65 74 |ronous c|alls ret| |00000b60| 75 72 6e 20 63 6f 6e 74 | 72 6f 6c 20 69 6d 6d 65 |urn cont|rol imme| |00000b70| 64 69 61 74 65 6c 79 20 | 74 6f 20 79 6f 75 72 20 |diately |to your | |00000b80| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 61 6e 64 20 |applicat|ion and | |00000b90| 70 65 72 66 6f 72 6d 20 | 74 68 65 69 72 20 6f 70 |perform |their op| |00000ba0| 65 72 61 74 69 6f 6e 73 | 20 69 6e 20 74 68 65 20 |erations| in the | |00000bb0| 62 61 63 6b 67 72 6f 75 | 6e 64 2c 20 77 68 69 63 |backgrou|nd, whic| |00000bc0| 68 20 6d 61 6b 65 73 20 | 61 73 79 6e 63 68 72 6f |h makes |asynchro| |00000bd0| 6e 6f 75 73 20 6f 70 65 | 72 61 74 69 6f 6e 73 20 |nous ope|rations | |00000be0| 73 6f 6d 65 77 68 61 74 | 20 74 72 69 63 6b 69 65 |somewhat| trickie| |00000bf0| 72 2e 20 4d 61 6e 79 20 | 64 65 76 65 6c 6f 70 65 |r. Many |develope| |00000c00| 72 73 20 66 65 65 6c 20 | 74 68 61 74 20 74 68 65 |rs feel |that the| |00000c10| 72 65 20 61 72 65 20 74 | 6f 6f 20 6d 61 6e 79 20 |re are t|oo many | |00000c20| 64 65 74 61 69 6c 73 20 | 74 6f 20 6d 61 6b 65 20 |details |to make | |00000c30| 61 73 79 6e 63 68 72 6f | 6e 6f 75 73 20 73 6f 75 |asynchro|nous sou| |00000c40| 6e 64 20 77 6f 72 74 68 | 77 68 69 6c 65 20 69 6e |nd worth|while in| |00000c50| 20 61 6e 20 61 70 70 6c | 69 63 61 74 69 6f 6e 20 | an appl|ication | |00000c60| 6e 6f 74 20 73 70 65 63 | 69 66 69 63 61 6c 6c 79 |not spec|ifically| |00000c70| 20 6f 72 69 65 6e 74 65 | 64 20 74 6f 77 61 72 64 | oriente|d toward| |00000c80| 20 73 6f 75 6e 64 2e 20 | 48 6f 77 65 76 65 72 2c | sound. |However,| |00000c90| 20 77 69 74 68 20 73 6f | 75 6e 64 20 69 6e 70 75 | with so|und inpu| |00000ca0| 74 20 64 65 76 69 63 65 | 73 20 62 65 63 6f 6d 69 |t device|s becomi| |00000cb0| 6e 67 20 6d 6f 72 65 20 | 63 6f 6d 6d 6f 6e 2c 20 |ng more |common, | |00000cc0| 74 68 65 20 6d 61 72 6b | 65 74 20 69 6d 70 65 74 |the mark|et impet| |00000cd0| 75 73 20 74 6f 20 61 64 | 64 20 73 6f 75 6e 64 20 |us to ad|d sound | |00000ce0| 69 73 20 67 72 6f 77 69 | 6e 67 2e 0d 54 68 69 73 |is growi|ng..This| |00000cf0| 20 61 72 74 69 63 6c 65 | 20 70 72 65 73 65 6e 74 | article| present| |00000d00| 73 20 74 68 65 20 41 73 | 79 6e 63 68 72 6f 6e 6f |s the As|ynchrono| |00000d10| 75 73 20 53 6f 75 6e 64 | 20 48 65 6c 70 65 72 2c |us Sound| Helper,| |00000d20| 20 61 20 63 6f 64 65 20 | 6d 6f 64 75 6c 65 20 64 | a code |module d| |00000d30| 65 73 69 67 6e 65 64 20 | 74 6f 20 74 61 6b 65 20 |esigned |to take | |00000d40| 6d 75 63 68 20 6f 66 20 | 74 68 65 20 68 65 61 72 |much of |the hear| |00000d50| 74 62 75 72 6e 20 6f 75 | 74 20 6f 66 20 61 73 79 |tburn ou|t of asy| |00000d60| 6e 63 68 72 6f 6e 6f 75 | 73 20 73 6f 75 6e 64 20 |nchronou|s sound | |00000d70| 69 6e 70 75 74 20 61 6e | 64 20 6f 75 74 70 75 74 |input an|d output| |00000d80| 2e 20 54 68 65 20 67 6f | 61 6c 73 20 6f 66 20 48 |. The go|als of H| |00000d90| 65 6c 70 65 72 2c 20 61 | 73 20 77 65 d5 6c 6c 20 |elper, a|s we.ll | |00000da0| 62 65 20 63 61 6c 6c 69 | 6e 67 20 69 74 20 66 72 |be calli|ng it fr| |00000db0| 6f 6d 20 6e 6f 77 20 6f | 6e 2c 20 61 72 65 20 74 |om now o|n, are t| |00000dc0| 68 72 65 65 66 6f 6c 64 | 3a 0d a5 09 50 72 6f 76 |hreefold|:...Prov| |00000dd0| 69 64 65 20 61 20 73 74 | 72 61 69 67 68 74 66 6f |ide a st|raightfo| |00000de0| 72 77 61 72 64 20 61 6e | 64 20 75 6e 63 6f 6d 70 |rward an|d uncomp| |00000df0| 6c 69 63 61 74 65 64 20 | 69 6e 74 65 72 66 61 63 |licated |interfac| |00000e00| 65 20 66 6f 72 20 61 73 | 79 6e 63 68 72 6f 6e 6f |e for as|ynchrono| |00000e10| 75 73 20 73 6f 75 6e 64 | 20 49 2f 4f 20 73 70 65 |us sound| I/O spe| |00000e20| 63 69 66 69 63 61 6c 6c | 79 20 74 61 69 6c 6f 72 |cificall|y tailor| |00000e30| 65 64 20 74 6f 77 61 72 | 64 20 63 6f 6d 6d 6f 6e |ed towar|d common| |00000e40| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 72 65 71 | applica|tion req| |00000e50| 75 69 72 65 6d 65 6e 74 | 73 2e 0d a5 09 45 6e 63 |uirement|s....Enc| |00000e60| 6f 75 72 61 67 65 20 64 | 65 76 65 6c 6f 70 65 72 |ourage d|eveloper| |00000e70| 73 20 74 6f 20 69 6e 63 | 6c 75 64 65 20 73 75 70 |s to inc|lude sup| |00000e80| 70 6f 72 74 20 66 6f 72 | 20 73 6f 75 6e 64 20 61 |port for| sound a| |00000e90| 73 20 61 20 73 74 61 6e | 64 61 72 64 20 74 79 70 |s a stan|dard typ| |00000ea0| 65 20 6f 66 20 64 61 74 | 61 2c 20 6a 75 73 74 20 |e of dat|a, just | |00000eb0| 6c 69 6b 65 20 74 65 78 | 74 20 6f 72 20 67 72 61 |like tex|t or gra| |00000ec0| 70 68 69 63 73 2e 0d 0d | 0d a5 09 46 75 6e 63 74 |phics...|...Funct| |00000ed0| 69 6f 6e 20 61 73 20 61 | 20 74 75 74 6f 72 69 61 |ion as a| tutoria| |00000ee0| 6c 20 6f 6e 20 68 6f 77 | 20 74 6f 20 70 65 72 66 |l on how| to perf| |00000ef0| 6f 72 6d 20 61 73 79 6e | 63 68 72 6f 6e 6f 75 73 |orm asyn|chronous| |00000f00| 20 73 6f 75 6e 64 20 69 | 6e 70 75 74 20 61 6e 64 | sound i|nput and| |00000f10| 20 6f 75 74 70 75 74 20 | 75 73 69 6e 67 20 74 68 | output |using th| |00000f20| 65 20 53 6f 75 6e 64 20 | 4d 61 6e 61 67 65 72 2e |e Sound |Manager.| |00000f30| 0d 48 65 6c 70 65 72 20 | 70 72 6f 76 69 64 65 73 |.Helper |provides| |00000f40| 20 74 77 6f 2d 74 69 65 | 72 65 64 20 73 75 70 70 | two-tie|red supp| |00000f50| 6f 72 74 d1 d2 65 61 73 | 79 d3 20 63 61 6c 6c 73 |ort..eas|y. calls| |00000f60| 20 66 6f 72 20 62 61 73 | 69 63 20 6f 70 65 72 61 | for bas|ic opera| |00000f70| 74 69 6f 6e 73 20 61 6e | 64 20 d2 61 64 76 61 6e |tions an|d .advan| |00000f80| 63 65 64 d3 20 63 61 6c | 6c 73 20 66 6f 72 20 6d |ced. cal|ls for m| |00000f90| 6f 72 65 20 63 6f 6d 70 | 6c 65 78 20 6f 70 65 72 |ore comp|lex oper| |00000fa0| 61 74 69 6f 6e 73 2e 20 | 59 6f 75 20 63 68 6f 6f |ations. |You choo| |00000fb0| 73 65 20 77 68 69 63 68 | 20 63 61 6c 6c 73 20 74 |se which| calls t| |00000fc0| 6f 20 75 73 65 20 64 65 | 70 65 6e 64 69 6e 67 20 |o use de|pending | |00000fd0| 6f 6e 20 79 6f 75 72 20 | 61 70 70 6c 69 63 61 74 |on your |applicat| |00000fe0| 69 6f 6e d5 73 20 73 70 | 65 63 69 66 69 63 20 6e |ion.s sp|ecific n| |00000ff0| 65 65 64 73 20 61 6e 64 | 20 75 73 65 72 20 69 6e |eeds and| user in| |00001000| 74 65 72 66 61 63 65 2e | 20 46 6f 72 20 73 69 6d |terface.| For sim| |00001010| 70 6c 65 20 61 73 79 6e | 63 68 72 6f 6e 6f 75 73 |ple asyn|chronous| |00001020| 20 72 65 63 6f 72 64 69 | 6e 67 20 61 6e 64 20 70 | recordi|ng and p| |00001030| 6c 61 79 62 61 63 6b 2c | 20 6f 6e 6c 79 20 61 20 |layback,| only a | |00001040| 66 65 77 20 72 6f 75 74 | 69 6e 65 73 20 61 72 65 |few rout|ines are| |00001050| 20 72 65 71 75 69 72 65 | 64 2e 20 4f 72 20 67 6f | require|d. Or go| |00001060| 20 61 6c 6c 20 6f 75 74 | 20 61 6e 64 20 75 73 65 | all out| and use| |00001070| 20 48 65 6c 70 65 72 20 | 72 6f 75 74 69 6e 65 73 | Helper |routines| |00001080| 20 74 6f 20 65 61 73 69 | 6c 79 20 70 72 6f 76 69 | to easi|ly provi| |00001090| 64 65 20 61 20 d2 73 6f | 75 6e 64 20 70 61 6c 65 |de a .so|und pale| |000010a0| 74 74 65 d3 20 77 69 74 | 68 20 74 61 70 65 2d 64 |tte. wit|h tape-d| |000010b0| 65 63 6b d0 6c 69 6b 65 | 20 63 6f 6e 74 72 6f 6c |eck.like| control| |000010c0| 73 20 66 6f 72 20 79 6f | 75 72 20 61 70 70 6c 69 |s for yo|ur appli| |000010d0| 63 61 74 69 6f 6e 2e 0d | 54 6f 20 74 6f 70 20 69 |cation..|To top i| |000010e0| 74 20 6f 66 66 2c 20 74 | 68 65 20 6f 76 65 72 68 |t off, t|he overh| |000010f0| 65 61 64 20 66 6f 72 20 | 48 65 6c 70 65 72 20 69 |ead for |Helper i| |00001100| 73 20 66 61 69 72 6c 79 | 20 73 6d 61 6c 6c 2e 20 |s fairly| small. | |00001110| 54 68 65 20 63 6f 64 65 | 20 63 6f 6d 70 69 6c 65 |The code| compile| |00001120| 73 20 74 6f 20 61 62 6f | 75 74 20 34 4b 2c 20 61 |s to abo|ut 4K, a| |00001130| 6e 64 20 69 74 20 61 64 | 64 73 20 38 36 20 62 79 |nd it ad|ds 86 by| |00001140| 74 65 73 20 6f 66 20 67 | 6c 6f 62 61 6c 20 64 61 |tes of g|lobal da| |00001150| 74 61 20 74 6f 20 79 6f | 75 72 20 61 70 70 6c 69 |ta to yo|ur appli| |00001160| 63 61 74 69 6f 6e 2e 20 | 41 74 20 72 75 6e 20 74 |cation. |At run t| |00001170| 69 6d 65 2c 20 69 74 20 | 75 73 65 73 20 61 72 6f |ime, it |uses aro| |00001180| 75 6e 64 20 34 4b 20 69 | 6e 20 79 6f 75 72 20 61 |und 4K i|n your a| |00001190| 70 70 6c 69 63 61 74 69 | 6f 6e d5 73 20 68 65 61 |pplicati|on.s hea| |000011a0| 70 2e 20 48 65 6c 70 65 | 72 20 75 73 65 73 20 63 |p. Helpe|r uses c| |000011b0| 6c 65 61 6e 20 53 6f 75 | 6e 64 20 4d 61 6e 61 67 |lean Sou|nd Manag| |000011c0| 65 72 20 74 65 63 68 6e | 69 71 75 65 73 d1 6e 6f |er techn|iques.no| |000011d0| 74 68 69 6e 67 20 73 6b | 61 6e 6b 79 20 74 68 61 |thing sk|anky tha| |000011e0| 74 20 6d 69 67 68 74 20 | 63 61 75 73 65 20 63 6f |t might |cause co| |000011f0| 6d 70 61 74 69 62 69 6c | 69 74 79 20 70 72 6f 62 |mpatibil|ity prob| |00001200| 6c 65 6d 73 20 69 6e 20 | 74 68 65 20 66 75 74 75 |lems in |the futu| |00001210| 72 65 2e 0d 48 4f 4f 4b | 49 4e 47 20 55 50 20 57 |re..HOOK|ING UP W| |00001220| 49 54 48 20 48 45 4c 50 | 45 52 20 0d 46 69 72 73 |ITH HELP|ER .Firs| |00001230| 74 20 6c 65 74 d5 73 20 | 74 61 6b 65 20 61 20 71 |t let.s |take a q| |00001240| 75 69 63 6b 20 6c 6f 6f | 6b 20 61 74 20 68 6f 77 |uick loo|k at how| |00001250| 20 48 65 6c 70 65 72 20 | 77 6f 72 6b 73 20 61 6e | Helper |works an| |00001260| 64 20 68 6f 77 20 79 6f | 75 72 20 61 70 70 6c 69 |d how yo|ur appli| |00001270| 63 61 74 69 6f 6e 20 75 | 73 65 73 20 69 74 2e 20 |cation u|ses it. | |00001280| 57 65 d5 6c 6c 20 6c 65 | 61 76 65 20 74 68 65 20 |We.ll le|ave the | |00001290| 64 65 74 61 69 6c 73 20 | 66 6f 72 20 6c 61 74 65 |details |for late| |000012a0| 72 2e 20 0d 42 65 66 6f | 72 65 20 79 6f 75 20 63 |r. .Befo|re you c| |000012b0| 61 6e 20 75 73 65 20 48 | 65 6c 70 65 72 20 79 6f |an use H|elper yo| |000012c0| 75 20 6e 65 65 64 20 74 | 6f 20 61 64 64 20 61 20 |u need t|o add a | |000012d0| 67 6c 6f 62 61 6c 20 42 | 6f 6f 6c 65 61 6e 20 66 |global B|oolean f| |000012e0| 6c 61 67 20 74 6f 20 79 | 6f 75 72 20 61 70 70 6c |lag to y|our appl| |000012f0| 69 63 61 74 69 6f 6e d1 | 74 68 65 20 61 74 74 65 |ication.|the atte| |00001300| 6e 74 69 6f 6e 20 66 6c | 61 67 2e 20 41 74 20 69 |ntion fl|ag. At i| |00001310| 6e 69 74 69 61 6c 69 7a | 61 74 69 6f 6e 20 74 69 |nitializ|ation ti| |00001320| 6d 65 2c 20 79 6f 75 72 | 20 61 70 70 6c 69 63 61 |me, your| applica| |00001330| 74 69 6f 6e 20 63 61 6c | 6c 73 20 48 65 6c 70 65 |tion cal|ls Helpe| |00001340| 72 d5 73 20 69 6e 69 74 | 69 61 6c 69 7a 61 74 69 |r.s init|ializati| |00001350| 6f 6e 20 72 6f 75 74 69 | 6e 65 20 61 6e 64 20 70 |on routi|ne and p| |00001360| 72 6f 76 69 64 65 73 20 | 74 68 65 20 61 64 64 72 |rovides |the addr| |00001370| 65 73 73 20 6f 66 20 74 | 68 65 20 61 74 74 65 6e |ess of t|he atten| |00001380| 74 69 6f 6e 20 66 6c 61 | 67 2e 20 49 6e 20 69 74 |tion fla|g. In it| |00001390| 73 20 6d 61 69 6e 20 65 | 76 65 6e 74 20 6c 6f 6f |s main e|vent loo| |000013a0| 70 2c 20 79 6f 75 72 20 | 61 70 70 6c 69 63 61 74 |p, your |applicat| |000013b0| 69 6f 6e 20 63 68 65 63 | 6b 73 20 74 68 65 20 76 |ion chec|ks the v| |000013c0| 61 6c 75 65 20 6f 66 20 | 74 68 65 20 61 74 74 65 |alue of |the atte| |000013d0| 6e 74 69 6f 6e 20 66 6c | 61 67 20 61 6e 64 2c 20 |ntion fl|ag and, | |000013e0| 69 66 20 74 72 75 65 2c | 20 63 61 6c 6c 73 20 48 |if true,| calls H| |000013f0| 65 6c 70 65 72 d5 73 20 | 69 64 6c 65 20 72 6f 75 |elper.s |idle rou| |00001400| 74 69 6e 65 2e 20 0d 42 | 65 63 61 75 73 65 20 48 |tine. .B|ecause H| |00001410| 65 6c 70 65 72 d5 73 20 | 6d 61 69 6e 20 66 75 6e |elper.s |main fun| |00001420| 63 74 69 6f 6e 20 69 73 | 20 74 6f 20 73 70 61 77 |ction is| to spaw| |00001430| 6e 20 61 73 79 6e 63 68 | 72 6f 6e 6f 75 73 20 73 |n asynch|ronous s| |00001440| 6f 75 6e 64 20 74 61 73 | 6b 73 2c 20 63 6f 6d 6d |ound tas|ks, comm| |00001450| 75 6e 69 63 61 74 69 6f | 6e 20 62 65 74 77 65 65 |unicatio|n betwee| |00001460| 6e 20 79 6f 75 72 20 61 | 70 70 6c 69 63 61 74 69 |n your a|pplicati| |00001470| 6f 6e 20 61 6e 64 20 48 | 65 6c 70 65 72 20 69 73 |on and H|elper is| |00001480| 20 63 61 72 72 69 65 64 | 20 6f 75 74 20 6f 6e 20 | carried| out on | |00001490| 61 6e 20 61 73 2d 6e 65 | 65 64 65 64 20 62 61 73 |an as-ne|eded bas| |000014a0| 69 73 2e 20 48 65 72 65 | 20 61 72 65 20 74 68 65 |is. Here| are the| |000014b0| 20 62 61 73 69 63 20 70 | 68 61 73 65 73 20 6f 66 | basic p|hases of| |000014c0| 20 63 6f 6d 6d 75 6e 69 | 63 61 74 69 6f 6e 20 66 | communi|cation f| |000014d0| 6f 72 20 61 20 74 79 70 | 69 63 61 6c 20 73 6f 75 |or a typ|ical sou| |000014e0| 6e 64 20 70 6c 61 79 62 | 61 63 6b 20 73 65 71 75 |nd playb|ack sequ| |000014f0| 65 6e 63 65 20 28 74 68 | 65 20 6e 75 6d 62 65 72 |ence (th|e number| |00001500| 73 20 63 6f 72 72 65 73 | 70 6f 6e 64 20 74 6f 20 |s corres|pond to | |00001510| 46 69 67 75 72 65 20 32 | 29 2e 0d 31 2e 09 59 6f |Figure 2|)..1..Yo| |00001520| 75 72 20 61 70 70 6c 69 | 63 61 74 69 6f 6e 20 74 |ur appli|cation t| |00001530| 65 6c 6c 73 20 48 65 6c | 70 65 72 20 74 6f 20 70 |ells Hel|per to p| |00001540| 6c 61 79 20 73 6f 6d 65 | 20 73 6f 75 6e 64 2e 0d |lay some| sound..| |00001550| 32 2e 09 48 65 6c 70 65 | 72 20 75 73 65 73 20 74 |2..Helpe|r uses t| |00001560| 68 65 20 53 6f 75 6e 64 | 20 4d 61 6e 61 67 65 72 |he Sound| Manager| |00001570| 20 74 6f 20 61 6c 6c 6f | 63 61 74 65 20 61 20 73 | to allo|cate a s| |00001580| 6f 75 6e 64 20 63 68 61 | 6e 6e 65 6c 20 61 6e 64 |ound cha|nnel and| |00001590| 20 62 65 67 69 6e 73 20 | 61 73 79 6e 63 68 72 6f | begins |asynchro| |000015a0| 6e 6f 75 73 20 70 6c 61 | 79 62 61 63 6b 20 6f 66 |nous pla|yback of| |000015b0| 20 79 6f 75 72 20 73 6f | 75 6e 64 2e 0d 33 2e 09 | your so|und..3..| |000015c0| 54 68 65 20 61 70 70 6c | 69 63 61 74 69 6f 6e 20 |The appl|ication | |000015d0| 67 6f 65 73 20 6f 6e 20 | 69 74 73 20 6d 65 72 72 |goes on |its merr| |000015e0| 79 20 77 61 79 2c 20 77 | 69 74 68 20 74 68 65 20 |y way, w|ith the | |000015f0| 73 6f 75 6e 64 20 70 6c | 61 79 69 6e 67 20 61 73 |sound pl|aying as| |00001600| 79 6e 63 68 72 6f 6e 6f | 75 73 6c 79 20 69 6e 20 |ynchrono|usly in | |00001610| 74 68 65 20 62 61 63 6b | 67 72 6f 75 6e 64 2e 0d |the back|ground..| |00001620| 34 2e 09 54 68 65 20 73 | 6f 75 6e 64 20 63 6f 6d |4..The s|ound com| |00001630| 70 6c 65 74 65 73 20 70 | 6c 61 79 62 61 63 6b 2e |pletes p|layback.| |00001640| 20 48 65 6c 70 65 72 20 | 68 61 73 20 73 65 74 20 | Helper |has set | |00001650| 75 70 20 61 20 73 6f 75 | 6e 64 20 63 6f 6d 6d 61 |up a sou|nd comma| |00001660| 6e 64 20 74 68 61 74 20 | 63 61 75 73 65 73 20 48 |nd that |causes H| |00001670| 65 6c 70 65 72 20 74 6f | 20 62 65 20 69 6e 66 6f |elper to| be info| |00001680| 72 6d 65 64 20 69 6d 6d | 65 64 69 61 74 65 6c 79 |rmed imm|ediately| |00001690| 20 75 70 6f 6e 20 63 6f | 6d 70 6c 65 74 69 6f 6e | upon co|mpletion| |000016a0| 20 6f 66 20 70 6c 61 79 | 62 61 63 6b 20 28 74 68 | of play|back (th| |000016b0| 69 73 20 6f 63 63 75 72 | 73 20 61 74 20 69 6e 74 |is occur|s at int| |000016c0| 65 72 72 75 70 74 20 74 | 69 6d 65 29 2e 20 41 74 |errupt t|ime). At| |000016d0| 20 74 68 61 74 20 74 69 | 6d 65 2c 20 48 65 6c 70 | that ti|me, Help| |000016e0| 65 72 20 73 65 74 73 20 | 74 68 65 20 61 70 70 6c |er sets |the appl| |000016f0| 69 63 61 74 69 6f 6e d5 | 73 20 67 6c 6f 62 61 6c |ication.|s global| |00001700| 20 61 74 74 65 6e 74 69 | 6f 6e 20 66 6c 61 67 2e | attenti|on flag.| |00001710| 0d 35 2e 20 54 68 65 20 | 6e 65 78 74 20 74 69 6d |.5. The |next tim| |00001720| 65 20 74 68 72 6f 75 67 | 68 20 79 6f 75 72 20 61 |e throug|h your a| |00001730| 70 70 6c 69 63 61 74 69 | 6f 6e d5 73 20 65 76 65 |pplicati|on.s eve| |00001740| 6e 74 20 6c 6f 6f 70 2c | 20 74 68 65 20 61 70 70 |nt loop,| the app| |00001750| 6c 69 63 61 74 69 6f 6e | 20 6e 6f 74 69 63 65 73 |lication| notices| |00001760| 20 74 68 61 74 20 74 68 | 65 20 61 74 74 65 6e 74 | that th|e attent| |00001770| 69 6f 6e 20 66 6c 61 67 | 20 69 73 20 73 65 74 20 |ion flag| is set | |00001780| 61 6e 64 20 63 61 6c 6c | 73 20 53 48 49 64 6c 65 |and call|s SHIdle| |00001790| 20 74 6f 20 66 72 65 65 | 20 75 70 20 74 68 65 20 | to free| up the | |000017a0| 73 6f 75 6e 64 20 63 68 | 61 6e 6e 65 6c 2e 0d 0d |sound ch|annel...| |000017b0| 0d 46 69 67 75 72 65 20 | 32 0d 41 70 70 6c 69 63 |.Figure |2.Applic| |000017c0| 61 74 69 6f 6e 20 20 53 | 6f 75 6e 64 20 4d 61 6e |ation S|ound Man| |000017d0| 61 67 65 72 20 49 6e 74 | 65 72 66 61 63 65 0d 57 |ager Int|erface.W| |000017e0| 68 65 6e 20 79 6f 75 72 | 20 61 70 70 6c 69 63 61 |hen your| applica| |000017f0| 74 69 6f 6e 20 74 65 72 | 6d 69 6e 61 74 65 73 2c |tion ter|minates,| |00001800| 20 69 74 20 63 61 6c 6c | 73 20 48 65 6c 70 65 72 | it call|s Helper| |00001810| d5 73 20 6b 69 6c 6c 20 | 72 6f 75 74 69 6e 65 2e |.s kill |routine.| |00001820| 20 48 65 6c 70 65 72 d5 | 73 20 6d 65 74 68 6f 64 | Helper.|s method| |00001830| 20 6f 66 20 63 6f 6d 6d | 75 6e 69 63 61 74 69 6f | of comm|unicatio| |00001840| 6e 20 77 69 74 68 20 74 | 68 65 20 61 70 70 6c 69 |n with t|he appli| |00001850| 63 61 74 69 6f 6e 20 6d | 69 6e 69 6d 69 7a 65 73 |cation m|inimizes| |00001860| 20 70 72 6f 63 65 73 73 | 69 6e 67 20 6f 76 65 72 | process|ing over| |00001870| 68 65 61 64 2e 20 42 79 | 20 75 73 69 6e 67 20 74 |head. By| using t| |00001880| 68 65 20 61 74 74 65 6e | 74 69 6f 6e 20 66 6c 61 |he atten|tion fla| |00001890| 67 20 73 63 68 65 6d 65 | 2c 20 79 6f 75 72 20 61 |g scheme|, your a| |000018a0| 70 70 6c 69 63 61 74 69 | 6f 6e 20 63 61 6c 6c 73 |pplicati|on calls| |000018b0| 20 48 65 6c 70 65 72 d5 | 73 20 69 64 6c 65 20 72 | Helper.|s idle r| |000018c0| 6f 75 74 69 6e 65 20 6f | 6e 6c 79 20 77 68 65 6e |outine o|nly when| |000018d0| 20 69 74 d5 73 20 72 65 | 61 6c 6c 79 20 6e 65 63 | it.s re|ally nec| |000018e0| 65 73 73 61 72 79 2e 20 | 54 68 69 73 20 63 6f 75 |essary. |This cou| |000018f0| 6c 64 20 62 65 20 69 6d | 70 6f 72 74 61 6e 74 20 |ld be im|portant | |00001900| 69 6e 20 67 61 6d 65 20 | 61 6e 64 20 6d 75 6c 74 |in game |and mult| |00001910| 69 6d 65 64 69 61 20 61 | 70 70 6c 69 63 61 74 69 |imedia a|pplicati| |00001920| 6f 6e 73 20 77 68 65 72 | 65 20 43 50 55 20 62 61 |ons wher|e CPU ba| |00001930| 6e 64 77 69 64 74 68 20 | 69 73 20 70 75 73 68 65 |ndwidth |is pushe| |00001940| 64 20 74 6f 20 74 68 65 | 20 6c 69 6d 69 74 2e 0d |d to the| limit..| |00001950| 48 45 4c 50 45 52 27 53 | 20 49 4e 54 45 52 46 41 |HELPER'S| INTERFA| |00001960| 43 45 0d 4e 6f 77 20 6c | 65 74 d5 73 20 74 61 6b |CE.Now l|et.s tak| |00001970| 65 20 61 20 6c 6f 6f 6b | 20 61 74 20 74 68 65 20 |e a look| at the | |00001980| 69 6e 74 65 72 66 61 63 | 65 73 20 61 6e 64 20 74 |interfac|es and t| |00001990| 68 65 20 62 61 73 69 63 | 20 75 73 65 73 20 6f 66 |he basic| uses of| |000019a0| 20 74 68 65 20 72 6f 75 | 74 69 6e 65 73 20 70 72 | the rou|tines pr| |000019b0| 6f 76 69 64 65 64 20 62 | 79 20 48 65 6c 70 65 72 |ovided b|y Helper| |000019c0| 2e 20 4c 61 74 65 72 20 | 77 65 d5 6c 6c 20 67 6f |. Later |we.ll go| |000019d0| 20 69 6e 74 6f 20 6d 6f | 72 65 20 64 65 74 61 69 | into mo|re detai| |000019e0| 6c 20 61 62 6f 75 74 20 | 68 6f 77 20 74 68 65 20 |l about |how the | |000019f0| 72 6f 75 74 69 6e 65 73 | 20 77 6f 72 6b 20 61 6e |routines| work an| |00001a00| 64 20 68 6f 77 20 74 6f | 20 75 73 65 20 74 68 65 |d how to| use the| |00001a10| 6d 2e 0d 49 4e 49 54 49 | 41 4c 49 5a 41 54 49 4f |m..INITI|ALIZATIO| |00001a20| 4e 2c 20 49 44 4c 45 2c | 20 41 4e 44 20 54 45 52 |N, IDLE,| AND TER| |00001a30| 4d 49 4e 41 54 49 4f 4e | 0d 70 61 73 63 61 6c 20 |MINATION|.pascal | |00001a40| 4f 53 45 72 72 20 53 48 | 49 6e 69 74 53 6f 75 6e |OSErr SH|InitSoun| |00001a50| 64 48 65 6c 70 65 72 28 | 42 6f 6f 6c 65 61 6e 20 |dHelper(|Boolean | |00001a60| 2a 61 74 74 6e 46 6c 61 | 67 2c 20 73 68 6f 72 74 |*attnFla|g, short| |00001a70| 20 6e 75 6d 43 68 61 6e | 6e 65 6c 73 29 3b 0d 70 | numChan|nels);.p| |00001a80| 61 73 63 61 6c 20 76 6f | 69 64 20 53 48 49 64 6c |ascal vo|id SHIdl| |00001a90| 65 28 76 6f 69 64 29 3b | 0d 70 61 73 63 61 6c 20 |e(void);|.pascal | |00001aa0| 76 6f 69 64 20 53 48 4b | 69 6c 6c 53 6f 75 6e 64 |void SHK|illSound| |00001ab0| 48 65 6c 70 65 72 28 76 | 6f 69 64 29 3b 0d 53 48 |Helper(v|oid);.SH| |00001ac0| 49 6e 69 74 53 6f 75 6e | 64 48 65 6c 70 65 72 20 |InitSoun|dHelper | |00001ad0| 69 6e 69 74 69 61 6c 69 | 7a 65 73 20 48 65 6c 70 |initiali|zes Help| |00001ae0| 65 72 2e 20 49 74 20 61 | 6c 6c 6f 63 61 74 65 73 |er. It a|llocates| |00001af0| 20 6d 65 6d 6f 72 79 2c | 20 73 6f 20 79 6f 75 20 | memory,| so you | |00001b00| 73 68 6f 75 6c 64 20 63 | 61 6c 6c 20 69 74 20 6e |should c|all it n| |00001b10| 65 61 72 20 74 68 65 20 | 62 65 67 69 6e 6e 69 6e |ear the |beginnin| |00001b20| 67 20 6f 66 20 79 6f 75 | 72 20 61 70 70 6c 69 63 |g of you|r applic| |00001b30| 61 74 69 6f 6e 2e 20 54 | 68 65 20 61 70 70 6c 69 |ation. T|he appli| |00001b40| 63 61 74 69 6f 6e 20 70 | 61 73 73 65 73 20 74 6f |cation p|asses to| |00001b50| 20 53 48 49 6e 69 74 53 | 6f 75 6e 64 48 65 6c 70 | SHInitS|oundHelp| |00001b60| 65 72 20 74 68 65 20 61 | 64 64 72 65 73 73 20 6f |er the a|ddress o| |00001b70| 66 20 74 68 65 20 42 6f | 6f 6c 65 61 6e 20 61 74 |f the Bo|olean at| |00001b80| 74 65 6e 74 69 6f 6e 20 | 66 6c 61 67 20 74 68 61 |tention |flag tha| |00001b90| 74 20 48 65 6c 70 65 72 | 20 75 73 65 73 20 74 6f |t Helper| uses to| |00001ba0| 20 69 6e 66 6f 72 6d 20 | 74 68 65 20 61 70 70 6c | inform |the appl| |00001bb0| 69 63 61 74 69 6f 6e 20 | 77 68 65 6e 20 69 74 20 |ication |when it | |00001bc0| 6e 65 65 64 73 20 61 74 | 74 65 6e 74 69 6f 6e 2e |needs at|tention.| |00001bd0| 20 0d 53 48 49 64 6c 65 | 20 70 65 72 66 6f 72 6d | .SHIdle| perform| |00001be0| 73 20 76 61 72 69 6f 75 | 73 20 63 6c 65 61 6e 75 |s variou|s cleanu| |00001bf0| 70 20 74 61 73 6b 73 2e | 20 43 61 6c 6c 20 53 48 |p tasks.| Call SH| |00001c00| 49 64 6c 65 20 77 68 65 | 6e 20 74 68 65 20 61 74 |Idle whe|n the at| |00001c10| 74 65 6e 74 69 6f 6e 20 | 66 6c 61 67 20 67 6f 65 |tention |flag goe| |00001c20| 73 20 74 72 75 65 2e 0d | 41 74 20 61 70 70 6c 69 |s true..|At appli| |00001c30| 63 61 74 69 6f 6e 20 74 | 65 72 6d 69 6e 61 74 69 |cation t|erminati| |00001c40| 6f 6e 2c 20 63 61 6c 6c | 20 53 48 4b 69 6c 6c 53 |on, call| SHKillS| |00001c50| 6f 75 6e 64 48 65 6c 70 | 65 72 2e 20 49 74 20 73 |oundHelp|er. It s| |00001c60| 74 6f 70 73 20 63 75 72 | 72 65 6e 74 20 72 65 63 |tops cur|rent rec| |00001c70| 6f 72 64 69 6e 67 20 61 | 6e 64 20 70 6c 61 79 62 |ording a|nd playb| |00001c80| 61 63 6b 20 61 6e 64 20 | 64 65 61 6c 6c 6f 63 61 |ack and |dealloca| |00001c90| 74 65 73 20 48 65 6c 70 | 65 72 d5 73 20 6d 65 6d |tes Help|er.s mem| |00001ca0| 6f 72 79 2e 0d 45 41 53 | 59 20 53 4f 55 4e 44 20 |ory..EAS|Y SOUND | |00001cb0| 4f 55 54 50 55 54 0d 70 | 61 73 63 61 6c 20 4f 53 |OUTPUT.p|ascal OS| |00001cc0| 45 72 72 20 53 48 50 6c | 61 79 42 79 49 44 28 73 |Err SHPl|ayByID(s| |00001cd0| 68 6f 72 74 20 72 65 73 | 49 44 2c 20 6c 6f 6e 67 |hort res|ID, long| |00001ce0| 20 2a 72 65 66 4e 75 6d | 29 3b 0d 70 61 73 63 61 | *refNum|);.pasca| |00001cf0| 6c 20 4f 53 45 72 72 20 | 53 48 50 6c 61 79 42 79 |l OSErr |SHPlayBy| |00001d00| 48 61 6e 64 6c 65 28 48 | 61 6e 64 6c 65 20 73 6f |Handle(H|andle so| |00001d10| 75 6e 64 2c 20 6c 6f 6e | 67 20 2a 72 65 66 4e 75 |und, lon|g *refNu| |00001d20| 6d 29 3b 0d 70 61 73 63 | 61 6c 20 4f 53 45 72 72 |m);.pasc|al OSErr| |00001d30| 20 53 48 50 6c 61 79 53 | 74 6f 70 28 6c 6f 6e 67 | SHPlayS|top(long| |00001d40| 20 72 65 66 4e 75 6d 29 | 3b 0d 70 61 73 63 61 6c | refNum)|;.pascal| |00001d50| 20 4f 53 45 72 72 20 53 | 48 50 6c 61 79 53 74 6f | OSErr S|HPlaySto| |00001d60| 70 41 6c 6c 28 76 6f 69 | 64 29 3b 0d 53 48 50 6c |pAll(voi|d);.SHPl| |00001d70| 61 79 42 79 49 44 20 61 | 6e 64 20 53 48 50 6c 61 |ayByID a|nd SHPla| |00001d80| 79 42 79 48 61 6e 64 6c | 65 20 70 72 6f 76 69 64 |yByHandl|e provid| |00001d90| 65 20 61 6e 20 65 61 73 | 79 20 77 61 79 20 74 6f |e an eas|y way to| |00001da0| 20 62 65 67 69 6e 20 61 | 73 79 6e 63 68 72 6f 6e | begin a|synchron| |00001db0| 6f 75 73 20 73 6f 75 6e | 64 20 70 6c 61 79 62 61 |ous soun|d playba| |00001dc0| 63 6b 2e 20 54 68 65 73 | 65 20 72 6f 75 74 69 6e |ck. Thes|e routin| |00001dd0| 65 73 20 72 65 74 75 72 | 6e 20 61 20 72 65 66 65 |es retur|n a refe| |00001de0| 72 65 6e 63 65 20 6e 75 | 6d 62 65 72 20 76 69 61 |rence nu|mber via| |00001df0| 20 74 68 65 20 72 65 66 | 4e 75 6d 20 70 61 72 61 | the ref|Num para| |00001e00| 6d 65 74 65 72 2e 20 54 | 68 69 73 20 72 65 66 65 |meter. T|his refe| |00001e10| 72 65 6e 63 65 20 6e 75 | 6d 62 65 72 20 63 61 6e |rence nu|mber can| |00001e20| 20 62 65 20 75 73 65 64 | 20 74 6f 20 73 74 6f 70 | be used| to stop| |00001e30| 20 70 6c 61 79 62 61 63 | 6b 20 61 6e 64 20 63 61 | playbac|k and ca| |00001e40| 6e 20 62 65 20 75 73 65 | 64 20 77 69 74 68 20 74 |n be use|d with t| |00001e50| 68 65 20 61 64 76 61 6e | 63 65 64 20 72 6f 75 74 |he advan|ced rout| |00001e60| 69 6e 65 73 20 64 65 73 | 63 72 69 62 65 64 20 6c |ines des|cribed l| |00001e70| 61 74 65 72 2e 20 49 66 | 20 79 6f 75 20 69 6e 74 |ater. If| you int| |00001e80| 65 6e 64 20 74 6f 20 73 | 69 6d 70 6c 79 20 74 72 |end to s|imply tr| |00001e90| 69 67 67 65 72 20 61 20 | 73 6f 75 6e 64 20 74 68 |igger a |sound th| |00001ea0| 61 74 20 79 6f 75 20 77 | 61 6e 74 20 74 6f 20 72 |at you w|ant to r| |00001eb0| 75 6e 20 74 6f 20 63 6f | 6d 70 6c 65 74 69 6f 6e |un to co|mpletion| |00001ec0| 20 28 6c 69 6b 65 20 61 | 20 67 75 6e 73 68 6f 74 | (like a| gunshot| |00001ed0| 20 73 6f 75 6e 64 20 69 | 6e 20 61 20 67 61 6d 65 | sound i|n a game| |00001ee0| 29 2c 20 79 6f 75 20 63 | 61 6e 20 70 61 73 73 20 |), you c|an pass | |00001ef0| 6e 69 6c 20 66 6f 72 20 | 74 68 65 20 72 65 66 4e |nil for |the refN| |00001f00| 75 6d 20 70 61 72 61 6d | 65 74 65 72 2c 20 74 68 |um param|eter, th| |00001f10| 65 72 65 62 79 20 69 67 | 6e 6f 72 69 6e 67 20 74 |ereby ig|noring t| |00001f20| 68 65 20 72 65 66 65 72 | 65 6e 63 65 20 6e 75 6d |he refer|ence num| |00001f30| 62 65 72 2e 0d 54 6f 20 | 73 74 6f 70 20 61 20 67 |ber..To |stop a g| |00001f40| 69 76 65 6e 20 73 6f 75 | 6e 64 20 6f 72 20 73 74 |iven sou|nd or st| |00001f50| 6f 70 20 61 6c 6c 20 70 | 6c 61 79 62 61 63 6b 2c |op all p|layback,| |00001f60| 20 75 73 65 20 53 48 50 | 6c 61 79 53 74 6f 70 20 | use SHP|layStop | |00001f70| 6f 72 20 53 48 50 6c 61 | 79 53 74 6f 70 41 6c 6c |or SHPla|yStopAll| |00001f80| 2e 0d 41 44 56 41 4e 43 | 45 44 20 53 4f 55 4e 44 |..ADVANC|ED SOUND| |00001f90| 20 4f 55 54 50 55 54 0d | 70 61 73 63 61 6c 20 4f | OUTPUT.|pascal O| |00001fa0| 53 45 72 72 20 53 48 50 | 6c 61 79 50 61 75 73 65 |SErr SHP|layPause| |00001fb0| 28 6c 6f 6e 67 20 72 65 | 66 4e 75 6d 29 3b 0d 70 |(long re|fNum);.p| |00001fc0| 61 73 63 61 6c 20 4f 53 | 45 72 72 20 53 48 50 6c |ascal OS|Err SHPl| |00001fd0| 61 79 43 6f 6e 74 69 6e | 75 65 28 6c 6f 6e 67 20 |ayContin|ue(long | |00001fe0| 72 65 66 4e 75 6d 29 3b | 0d 70 61 73 63 61 6c 20 |refNum);|.pascal | |00001ff0| 53 48 50 6c 61 79 53 74 | 61 74 20 53 48 50 6c 61 |SHPlaySt|at SHPla| |00002000| 79 53 74 61 74 75 73 28 | 6c 6f 6e 67 20 72 65 66 |yStatus(|long ref| |00002010| 4e 75 6d 29 3b 0d 70 61 | 73 63 61 6c 20 4f 53 45 |Num);.pa|scal OSE| |00002020| 72 72 20 53 48 47 65 74 | 43 68 61 6e 6e 65 6c 28 |rr SHGet|Channel(| |00002030| 6c 6f 6e 67 20 72 65 66 | 4e 75 6d 2c 20 53 6e 64 |long ref|Num, Snd| |00002040| 43 68 61 6e 6e 65 6c 50 | 74 72 20 2a 63 68 61 6e |ChannelP|tr *chan| |00002050| 6e 65 6c 29 3b 0d 49 66 | 20 79 6f 75 20 77 61 6e |nel);.If| you wan| |00002060| 74 20 6d 6f 72 65 20 63 | 6f 6e 74 72 6f 6c 20 6f |t more c|ontrol o| |00002070| 76 65 72 20 74 68 65 20 | 70 6c 61 79 62 61 63 6b |ver the |playback| |00002080| 20 70 72 6f 63 65 73 73 | 2c 20 74 68 65 73 65 20 | process|, these | |00002090| 72 6f 75 74 69 6e 65 73 | 20 77 69 6c 6c 20 62 65 |routines| will be| |000020a0| 20 6f 66 20 69 6e 74 65 | 72 65 73 74 2e 20 53 48 | of inte|rest. SH| |000020b0| 50 6c 61 79 50 61 75 73 | 65 20 70 61 75 73 65 73 |PlayPaus|e pauses| |000020c0| 20 74 68 65 20 70 6c 61 | 79 62 61 63 6b 20 6f 66 | the pla|yback of| |000020d0| 20 61 20 73 6f 75 6e 64 | 2c 20 6c 69 6b 65 20 74 | a sound|, like t| |000020e0| 68 65 20 70 61 75 73 65 | 20 62 75 74 74 6f 6e 20 |he pause| button | |000020f0| 6f 6e 20 61 20 74 61 70 | 65 20 64 65 63 6b 2e 20 |on a tap|e deck. | |00002100| 53 48 50 6c 61 79 43 6f | 6e 74 69 6e 75 65 20 63 |SHPlayCo|ntinue c| |00002110| 6f 6e 74 69 6e 75 65 73 | 20 70 6c 61 79 62 61 63 |ontinues| playbac| |00002120| 6b 20 6f 66 20 61 20 73 | 6f 75 6e 64 20 74 68 61 |k of a s|ound tha| |00002130| 74 20 77 61 73 20 70 72 | 65 76 69 6f 75 73 6c 79 |t was pr|eviously| |00002140| 20 70 61 75 73 65 64 2e | 20 55 73 65 20 53 48 50 | paused.| Use SHP| |00002150| 6c 61 79 53 74 61 74 75 | 73 20 74 6f 20 66 69 6e |layStatu|s to fin| |00002160| 64 20 6f 75 74 20 74 68 | 65 20 73 74 61 74 75 73 |d out th|e status| |00002170| 20 6f 66 20 61 20 73 6f | 75 6e 64 d1 66 69 6e 69 | of a so|und.fini| |00002180| 73 68 65 64 2c 20 70 6c | 61 79 69 6e 67 2c 20 6f |shed, pl|aying, o| |00002190| 72 20 70 61 75 73 65 64 | 2e 20 49 66 20 79 6f 75 |r paused|. If you| |000021a0| 20 77 61 6e 74 20 74 6f | 20 73 65 6e 64 20 63 6f | want to| send co| |000021b0| 6d 6d 61 6e 64 73 20 64 | 69 72 65 63 74 6c 79 20 |mmands d|irectly | |000021c0| 74 6f 20 61 20 73 6f 75 | 6e 64 20 63 68 61 6e 6e |to a sou|nd chann| |000021d0| 65 6c 20 74 68 61 74 20 | 77 61 73 20 61 6c 6c 6f |el that |was allo| |000021e0| 63 61 74 65 64 20 62 79 | 20 48 65 6c 70 65 72 2c |cated by| Helper,| |000021f0| 20 75 73 65 20 53 48 47 | 65 74 43 68 61 6e 6e 65 | use SHG|etChanne| |00002200| 6c 2e 20 59 6f 75 20 6d | 69 67 68 74 20 77 61 6e |l. You m|ight wan| |00002210| 74 20 74 6f 20 73 65 6e | 64 20 73 6f 75 6e 64 20 |t to sen|d sound | |00002220| 63 6f 6d 6d 61 6e 64 73 | 20 69 6e 20 79 6f 75 72 |commands| in your| |00002230| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 2c 20 66 6f | applica|tion, fo| |00002240| 72 20 65 78 61 6d 70 6c | 65 2c 20 74 6f 20 70 6c |r exampl|e, to pl| |00002250| 61 79 20 63 6f 6e 74 69 | 6e 75 6f 75 73 20 6c 6f |ay conti|nuous lo| |00002260| 6f 70 65 64 20 62 61 63 | 6b 67 72 6f 75 6e 64 20 |oped bac|kground | |00002270| 6d 75 73 69 63 2e 0d 45 | 41 53 59 20 53 4f 55 4e |music..E|ASY SOUN| |00002280| 44 20 49 4e 50 55 54 0d | 70 61 73 63 61 6c 20 4f |D INPUT.|pascal O| |00002290| 53 45 72 72 20 53 48 52 | 65 63 6f 72 64 53 74 61 |SErr SHR|ecordSta| |000022a0| 72 74 28 73 68 6f 72 74 | 20 6d 61 78 4b 2c 20 4f |rt(short| maxK, O| |000022b0| 53 54 79 70 65 20 71 75 | 61 6c 69 74 79 2c 20 42 |SType qu|ality, B| |000022c0| 6f 6f 6c 65 61 6e 20 2a | 64 6f 6e 65 46 6c 61 67 |oolean *|doneFlag| |000022d0| 29 3b 0d 70 61 73 63 61 | 6c 20 4f 53 45 72 72 20 |);.pasca|l OSErr | |000022e0| 53 48 47 65 74 52 65 63 | 6f 72 64 65 64 53 6f 75 |SHGetRec|ordedSou| |000022f0| 6e 64 28 48 61 6e 64 6c | 65 20 2a 74 68 65 53 6f |nd(Handl|e *theSo| |00002300| 75 6e 64 29 3b 0d 70 61 | 73 63 61 6c 20 4f 53 45 |und);.pa|scal OSE| |00002310| 72 72 20 53 48 52 65 63 | 6f 72 64 53 74 6f 70 28 |rr SHRec|ordStop(| |00002320| 76 6f 69 64 29 3b 0d 54 | 68 65 73 65 20 61 72 65 |void);.T|hese are| |00002330| 20 74 68 65 20 74 68 72 | 65 65 20 62 61 73 69 63 | the thr|ee basic| |00002340| 20 72 6f 75 74 69 6e 65 | 73 20 66 6f 72 20 72 65 | routine|s for re| |00002350| 63 6f 72 64 69 6e 67 20 | 73 6f 75 6e 64 20 74 68 |cording |sound th| |00002360| 72 6f 75 67 68 20 61 20 | 73 6f 75 6e 64 20 69 6e |rough a |sound in| |00002370| 70 75 74 20 64 65 76 69 | 63 65 2e 20 54 6f 20 62 |put devi|ce. To b| |00002380| 65 67 69 6e 20 61 73 79 | 6e 63 68 72 6f 6e 6f 75 |egin asy|nchronou| |00002390| 73 20 73 6f 75 6e 64 20 | 72 65 63 6f 72 64 69 6e |s sound |recordin| |000023a0| 67 2c 20 75 73 65 20 53 | 48 52 65 63 6f 72 64 53 |g, use S|HRecordS| |000023b0| 74 61 72 74 2e 20 54 68 | 65 20 61 70 70 6c 69 63 |tart. Th|e applic| |000023c0| 61 74 69 6f 6e 20 70 61 | 73 73 65 73 20 74 68 65 |ation pa|sses the| |000023d0| 20 61 64 64 72 65 73 73 | 20 6f 66 20 61 20 42 6f | address| of a Bo| |000023e0| 6f 6c 65 61 6e d1 61 20 | 72 65 63 6f 72 64 69 6e |olean.a |recordin| |000023f0| 67 2d 63 6f 6d 70 6c 65 | 74 65 64 20 66 6c 61 67 |g-comple|ted flag| |00002400| d1 74 68 61 74 20 74 65 | 6c 6c 73 20 74 68 65 20 |.that te|lls the | |00002410| 61 70 70 6c 69 63 61 74 | 69 6f 6e 0d 77 68 65 6e |applicat|ion.when| |00002420| 20 74 68 65 20 72 65 63 | 6f 72 64 69 6e 67 20 69 | the rec|ording i| |00002430| 73 20 63 6f 6d 70 6c 65 | 74 65 2e 20 4f 6e 63 65 |s comple|te. Once| |00002440| 20 63 6f 6d 70 6c 65 74 | 65 2c 20 74 68 65 20 61 | complet|e, the a| |00002450| 70 70 6c 69 63 61 74 69 | 6f 6e 20 63 61 6c 6c 73 |pplicati|on calls| |00002460| 20 53 48 47 65 74 52 65 | 63 6f 72 64 65 64 53 6f | SHGetRe|cordedSo| |00002470| 75 6e 64 20 74 6f 20 72 | 65 74 72 69 65 76 65 20 |und to r|etrieve | |00002480| 61 20 73 6f 75 6e 64 20 | 68 61 6e 64 6c 65 2e 20 |a sound |handle. | |00002490| 54 68 65 20 68 61 6e 64 | 6c 65 20 69 73 20 73 75 |The hand|le is su| |000024a0| 69 74 61 62 6c 65 20 66 | 6f 72 20 70 6c 61 79 62 |itable f|or playb| |000024b0| 61 63 6b 20 77 69 74 68 | 20 53 48 50 6c 61 79 42 |ack with| SHPlayB| |000024c0| 79 48 61 6e 64 6c 65 20 | 6f 72 20 74 6f 20 62 65 |yHandle |or to be| |000024d0| 20 77 72 69 74 74 65 6e | 20 6f 75 74 20 61 73 20 | written| out as | |000024e0| 61 20 27 73 6e 64 20 27 | 20 72 65 73 6f 75 72 63 |a 'snd '| resourc| |000024f0| 65 2e 20 54 6f 20 73 74 | 6f 70 20 72 65 63 6f 72 |e. To st|op recor| |00002500| 64 69 6e 67 20 69 6d 6d | 65 64 69 61 74 65 6c 79 |ding imm|ediately| |00002510| 20 28 61 73 20 77 69 74 | 68 20 74 68 65 20 73 74 | (as wit|h the st| |00002520| 6f 70 20 62 75 74 74 6f | 6e 20 6f 6e 20 61 20 74 |op butto|n on a t| |00002530| 61 70 65 20 72 65 63 6f | 72 64 65 72 29 2c 20 75 |ape reco|rder), u| |00002540| 73 65 20 53 48 52 65 63 | 6f 72 64 53 74 6f 70 2e |se SHRec|ordStop.| |00002550| 0d 41 44 56 41 4e 43 45 | 44 20 53 4f 55 4e 44 20 |.ADVANCE|D SOUND | |00002560| 49 4e 50 55 54 0d 70 61 | 73 63 61 6c 20 4f 53 45 |INPUT.pa|scal OSE| |00002570| 72 72 20 53 48 52 65 63 | 6f 72 64 50 61 75 73 65 |rr SHRec|ordPause| |00002580| 28 76 6f 69 64 29 3b 0d | 70 61 73 63 61 6c 20 4f |(void);.|pascal O| |00002590| 53 45 72 72 20 53 48 52 | 65 63 6f 72 64 43 6f 6e |SErr SHR|ecordCon| |000025a0| 74 69 6e 75 65 28 76 6f | 69 64 29 3b 0d 70 61 73 |tinue(vo|id);.pas| |000025b0| 63 61 6c 20 4f 53 45 72 | 72 20 53 48 52 65 63 6f |cal OSEr|r SHReco| |000025c0| 72 64 53 74 61 74 75 73 | 28 53 48 52 65 63 6f 72 |rdStatus|(SHRecor| |000025d0| 64 53 74 61 74 75 73 52 | 65 63 20 2a 72 65 63 6f |dStatusR|ec *reco| |000025e0| 72 64 53 74 61 74 75 73 | 29 3b 0d 54 6f 20 70 61 |rdStatus|);.To pa| |000025f0| 75 73 65 20 72 65 63 6f | 72 64 69 6e 67 2c 20 75 |use reco|rding, u| |00002600| 73 65 20 53 48 52 65 63 | 6f 72 64 50 61 75 73 65 |se SHRec|ordPause| |00002610| 2e 20 54 6f 20 63 6f 6e | 74 69 6e 75 65 20 70 72 |. To con|tinue pr| |00002620| 65 76 69 6f 75 73 6c 79 | 20 70 61 75 73 65 64 20 |eviously| paused | |00002630| 72 65 63 6f 72 64 69 6e | 67 2c 20 75 73 65 20 53 |recordin|g, use S| |00002640| 48 52 65 63 6f 72 64 43 | 6f 6e 74 69 6e 75 65 2e |HRecordC|ontinue.| |00002650| 20 55 73 65 20 53 48 52 | 65 63 6f 72 64 53 74 61 | Use SHR|ecordSta| |00002660| 74 75 73 20 74 6f 20 67 | 65 74 20 69 6e 66 6f 72 |tus to g|et infor| |00002670| 6d 61 74 69 6f 6e 20 61 | 62 6f 75 74 20 74 68 65 |mation a|bout the| |00002680| 20 73 74 61 74 75 73 20 | 6f 66 20 72 65 63 6f 72 | status |of recor| |00002690| 64 69 6e 67 2e 20 54 68 | 69 73 20 73 74 61 74 75 |ding. Th|is statu| |000026a0| 73 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 20 69 6e |s inform|ation in| |000026b0| 63 6c 75 64 65 73 20 74 | 68 65 20 63 75 72 72 65 |cludes t|he curre| |000026c0| 6e 74 20 69 6e 70 75 74 | 20 6c 65 76 65 6c 20 28 |nt input| level (| |000026d0| 77 68 69 63 68 20 63 6f | 75 6c 64 20 62 65 20 75 |which co|uld be u| |000026e0| 73 65 64 20 74 6f 20 64 | 72 61 77 20 61 20 74 61 |sed to d|raw a ta| |000026f0| 70 65 2d 64 65 63 6b d0 | 6c 69 6b 65 20 6c 65 76 |pe-deck.|like lev| |00002700| 65 6c 20 6d 65 74 65 72 | 29 2c 20 74 68 65 20 61 |el meter|), the a| |00002710| 6d 6f 75 6e 74 20 6f 66 | 20 73 6f 75 6e 64 20 74 |mount of| sound t| |00002720| 68 61 74 d5 73 20 62 65 | 65 6e 20 72 65 63 6f 72 |hat.s be|en recor| |00002730| 64 65 64 20 28 77 69 74 | 68 20 72 65 73 70 65 63 |ded (wit|h respec| |00002740| 74 20 74 6f 20 74 68 65 | 20 6d 61 78 69 6d 75 6d |t to the| maximum| |00002750| 29 2c 20 61 6e 64 20 77 | 68 65 74 68 65 72 20 74 |), and w|hether t| |00002760| 68 65 20 72 65 63 6f 72 | 64 69 6e 67 20 69 73 20 |he recor|ding is | |00002770| 66 69 6e 69 73 68 65 64 | 2c 20 72 65 63 6f 72 64 |finished|, record| |00002780| 69 6e 67 2c 20 6f 72 20 | 70 61 75 73 65 64 2e 0d |ing, or |paused..| |00002790| 48 45 4c 50 45 52 27 53 | 20 44 41 54 41 20 53 54 |HELPER'S| DATA ST| |000027a0| 52 55 43 54 55 52 45 53 | 0d 48 65 6c 70 65 72 20 |RUCTURES|.Helper | |000027b0| 75 73 65 73 20 74 68 72 | 65 65 20 69 6e 74 65 72 |uses thr|ee inter| |000027c0| 6e 61 6c 20 64 61 74 61 | 20 73 74 72 75 63 74 75 |nal data| structu| |000027d0| 72 65 73 20 74 6f 20 6b | 65 65 70 20 74 72 61 63 |res to k|eep trac| |000027e0| 6b 20 6f 66 20 72 65 63 | 6f 72 64 69 6e 67 20 61 |k of rec|ording a| |000027f0| 6e 64 20 70 6c 61 79 62 | 61 63 6b 2e 0d 74 79 70 |nd playb|ack..typ| |00002800| 65 64 65 66 20 73 74 72 | 75 63 74 20 7b 0d 09 73 |edef str|uct {..s| |00002810| 68 6f 72 74 09 6e 75 6d | 4f 75 74 52 65 63 73 3b |hort.num|OutRecs;| |00002820| 09 2f 2f 20 54 68 65 20 | 6e 75 6d 62 65 72 20 6f |.// The |number o| |00002830| 66 20 6f 75 74 70 75 74 | 20 72 65 63 6f 72 64 73 |f output| records| |00002840| 20 69 6e 20 6f 75 74 41 | 72 72 61 79 2e 0d 09 53 | in outA|rray...S| |00002850| 48 4f 75 74 52 65 63 09 | 2a 6f 75 74 41 72 72 61 |HOutRec.|*outArra| |00002860| 79 3b 09 2f 2f 20 4f 75 | 72 20 70 72 65 61 6c 6c |y;.// Ou|r preall| |00002870| 6f 63 61 74 65 64 20 6f | 75 74 70 75 74 20 72 65 |ocated o|utput re| |00002880| 63 6f 72 64 73 2e 0d 09 | 20 6c 6f 6e 67 09 6e 65 |cords...| long.ne| |00002890| 78 74 52 65 66 3b 09 2f | 2f 20 4e 65 78 74 20 61 |xtRef;./|/ Next a| |000028a0| 76 61 69 6c 61 62 6c 65 | 20 6f 75 74 70 75 74 20 |vailable| output | |000028b0| 72 65 66 65 72 65 6e 63 | 65 20 6e 75 6d 62 65 72 |referenc|e number| |000028c0| 2e 0d 7d 20 53 48 4f 75 | 74 70 75 74 56 61 72 73 |..} SHOu|tputVars| |000028d0| 3b 0d 54 68 65 20 53 48 | 4f 75 74 70 75 74 56 61 |;.The SH|OutputVa| |000028e0| 72 73 20 72 65 63 6f 72 | 64 20 63 6f 6e 74 61 69 |rs recor|d contai| |000028f0| 6e 73 20 61 6e 20 61 72 | 72 61 79 20 6f 66 20 53 |ns an ar|ray of S| |00002900| 48 4f 75 74 52 65 63 20 | 72 65 63 6f 72 64 73 2e |HOutRec |records.| |00002910| 20 54 68 65 20 6e 75 6d | 4f 75 74 52 65 63 73 20 | The num|OutRecs | |00002920| 66 69 65 6c 64 20 74 65 | 6c 6c 73 20 68 6f 77 20 |field te|lls how | |00002930| 6d 61 6e 79 20 61 72 65 | 20 69 6e 20 74 68 65 20 |many are| in the | |00002940| 61 72 72 61 79 2e 20 54 | 68 65 73 65 20 72 65 63 |array. T|hese rec| |00002950| 6f 72 64 73 2c 20 6f 6e | 65 20 66 6f 72 20 65 61 |ords, on|e for ea| |00002960| 63 68 20 61 6c 6c 6f 63 | 61 74 65 64 20 63 68 61 |ch alloc|ated cha| |00002970| 6e 6e 65 6c 2c 20 68 6f | 6c 64 20 69 6e 66 6f 72 |nnel, ho|ld infor| |00002980| 6d 61 74 69 6f 6e 20 61 | 62 6f 75 74 20 63 75 72 |mation a|bout cur| |00002990| 72 65 6e 74 6c 79 20 70 | 6c 61 79 69 6e 67 20 73 |rently p|laying s| |000029a0| 6f 75 6e 64 73 2e 20 54 | 68 65 79 d5 72 65 20 72 |ounds. T|hey.re r| |000029b0| 65 75 73 65 64 20 77 68 | 65 6e 20 73 6f 75 6e 64 |eused wh|en sound| |000029c0| 73 20 68 61 76 65 20 63 | 6f 6d 70 6c 65 74 65 64 |s have c|ompleted| |000029d0| 2e 20 54 68 65 20 53 48 | 4f 75 74 70 75 74 56 61 |. The SH|OutputVa| |000029e0| 72 73 20 72 65 63 6f 72 | 64 20 61 6c 73 6f 20 6b |rs recor|d also k| |000029f0| 65 65 70 73 20 74 72 61 | 63 6b 20 6f 66 20 74 68 |eeps tra|ck of th| |00002a00| 65 20 6e 65 78 74 20 61 | 76 61 69 6c 61 62 6c 65 |e next a|vailable| |00002a10| 20 6f 75 74 70 75 74 20 | 72 65 66 65 72 65 6e 63 | output |referenc| |00002a20| 65 20 6e 75 6d 62 65 72 | 2c 20 69 6e 20 74 68 65 |e number|, in the| |00002a30| 20 66 69 65 6c 64 20 6e | 65 78 74 52 65 66 2e 20 | field n|extRef. | |00002a40| 54 68 65 20 72 65 66 65 | 72 65 6e 63 65 20 6e 75 |The refe|rence nu| |00002a50| 6d 62 65 72 73 20 61 72 | 65 20 75 6e 69 71 75 65 |mbers ar|e unique| |00002a60| 20 28 6d 6f 64 75 6c 6f | 20 32 2c 31 34 37 2c 34 | (modulo| 2,147,4| |00002a70| 38 33 2c 36 34 37 29 2e | 0d 74 79 70 65 64 65 66 |83,647).|.typedef| |00002a80| 20 73 74 72 75 63 74 20 | 7b 0d 53 6e 64 43 68 61 | struct |{.SndCha| |00002a90| 6e 6e 65 6c 20 63 68 61 | 6e 6e 65 6c 3b 09 2f 2f |nnel cha|nnel;.//| |00002aa0| 20 4f 75 72 20 73 6f 75 | 6e 64 20 63 68 61 6e 6e | Our sou|nd chann| |00002ab0| 65 6c 2e 0d 09 6c 6f 6e | 67 09 72 65 66 4e 75 6d |el...lon|g.refNum| |00002ac0| 3b 09 2f 2f 20 4f 75 72 | 20 48 65 6c 70 65 72 20 |;.// Our| Helper | |00002ad0| 72 65 66 65 72 65 6e 63 | 65 20 6e 75 6d 62 65 72 |referenc|e number| |00002ae0| 2e 0d 09 48 61 6e 64 6c | 65 09 73 6f 75 6e 64 3b |...Handl|e.sound;| |00002af0| 09 2f 2f 20 54 68 65 20 | 73 6f 75 6e 64 20 77 65 |.// The |sound we| |00002b00| 27 72 65 20 70 6c 61 79 | 69 6e 67 2e 0d 09 46 69 |'re play|ing...Fi| |00002b10| 78 65 64 09 72 61 74 65 | 3b 09 2f 2f 20 53 61 6d |xed.rate|;.// Sam| |00002b20| 70 6c 65 64 20 73 6f 75 | 6e 64 20 70 6c 61 79 62 |pled sou|nd playb| |00002b30| 61 63 6b 20 72 61 74 65 | 2e 0d 09 63 68 61 72 09 |ack rate|...char.| |00002b40| 68 61 6e 64 6c 65 53 74 | 61 74 65 3b 09 2f 2f 20 |handleSt|ate;.// | |00002b50| 54 68 65 20 68 61 6e 64 | 6c 65 20 73 74 61 74 65 |The hand|le state| |00002b60| 20 66 6f 72 20 74 68 69 | 73 20 68 61 6e 64 6c 65 | for thi|s handle| |00002b70| 2e 0d 09 42 6f 6f 6c 65 | 61 6e 09 69 6e 55 73 65 |...Boole|an.inUse| |00002b80| 3b 09 2f 2f 20 54 65 6c | 6c 73 20 77 68 65 74 68 |;.// Tel|ls wheth| |00002b90| 65 72 20 74 68 69 73 20 | 53 48 4f 75 74 52 65 63 |er this |SHOutRec| |00002ba0| 20 69 73 20 69 6e 20 75 | 73 65 2e 0d 09 42 6f 6f | is in u|se...Boo| |00002bb0| 6c 65 61 6e 09 70 61 75 | 73 65 64 3b 09 2f 2f 20 |lean.pau|sed;.// | |00002bc0| 54 65 6c 6c 73 20 77 68 | 65 74 68 65 72 20 74 68 |Tells wh|ether th| |00002bd0| 69 73 20 73 6f 75 6e 64 | 20 69 73 20 70 61 75 73 |is sound| is paus| |00002be0| 65 64 2e 0d 7d 20 53 48 | 4f 75 74 52 65 63 2c 20 |ed..} SH|OutRec, | |00002bf0| 2a 53 48 4f 75 74 50 74 | 72 3b 0d 0d 0d 41 6e 20 |*SHOutPt|r;...An | |00002c00| 53 48 4f 75 74 52 65 63 | 20 72 65 63 6f 72 64 d5 |SHOutRec| record.| |00002c10| 73 20 66 69 72 73 74 20 | 66 69 65 6c 64 2c 20 63 |s first |field, c| |00002c20| 68 61 6e 6e 65 6c 2c 20 | 63 6f 6e 74 61 69 6e 73 |hannel, |contains| |00002c30| 20 74 68 65 20 61 63 74 | 75 61 6c 20 53 6f 75 6e | the act|ual Soun| |00002c40| 64 20 4d 61 6e 61 67 65 | 72 20 53 6e 64 43 68 61 |d Manage|r SndCha| |00002c50| 6e 6e 65 6c 20 75 73 65 | 64 20 74 6f 20 70 6c 61 |nnel use|d to pla| |00002c60| 79 20 74 68 65 20 73 6f | 75 6e 64 2e 20 54 68 65 |y the so|und. The| |00002c70| 20 73 6f 75 6e 64 20 72 | 65 66 65 72 65 6e 63 65 | sound r|eference| |00002c80| 20 6e 75 6d 62 65 72 20 | 61 73 73 6f 63 69 61 74 | number |associat| |00002c90| 65 64 20 77 69 74 68 20 | 74 68 69 73 20 73 6f 75 |ed with |this sou| |00002ca0| 6e 64 20 28 74 68 65 20 | 6f 6e 65 20 70 61 73 73 |nd (the |one pass| |00002cb0| 65 64 20 62 61 63 6b 20 | 74 6f 20 74 68 65 20 61 |ed back |to the a| |00002cc0| 70 70 6c 69 63 61 74 69 | 6f 6e 29 20 69 73 20 73 |pplicati|on) is s| |00002cd0| 74 6f 72 65 64 20 69 6e | 20 74 68 65 20 72 65 66 |tored in| the ref| |00002ce0| 4e 75 6d 20 66 69 65 6c | 64 2e 20 41 20 68 61 6e |Num fiel|d. A han| |00002cf0| 64 6c 65 20 74 6f 20 74 | 68 65 20 73 6f 75 6e 64 |dle to t|he sound| |00002d00| 20 77 65 d5 72 65 20 70 | 6c 61 79 69 6e 67 20 69 | we.re p|laying i| |00002d10| 73 20 73 74 6f 72 65 64 | 20 69 6e 20 74 68 65 20 |s stored| in the | |00002d20| 73 6f 75 6e 64 20 66 69 | 65 6c 64 2e 20 54 68 65 |sound fi|eld. The| |00002d30| 20 72 61 74 65 20 66 69 | 65 6c 64 20 68 6f 6c 64 | rate fi|eld hold| |00002d40| 73 20 74 68 65 20 73 61 | 6d 70 6c 65 20 70 6c 61 |s the sa|mple pla| |00002d50| 79 62 61 63 6b 20 72 61 | 74 65 20 6f 66 20 73 61 |yback ra|te of sa| |00002d60| 6d 70 6c 65 64 20 73 6f | 75 6e 64 73 2c 20 77 68 |mpled so|unds, wh| |00002d70| 69 63 68 20 69 73 20 75 | 73 65 64 20 77 68 65 6e |ich is u|sed when| |00002d80| 20 70 61 75 73 69 6e 67 | 20 73 61 6d 70 6c 65 64 | pausing| sampled| |00002d90| 20 73 6f 75 6e 64 73 2e | 20 54 68 65 20 68 61 6e | sounds.| The han| |00002da0| 64 6c 65 53 74 61 74 65 | 20 66 69 65 6c 64 20 63 |dleState| field c| |00002db0| 6f 6e 74 61 69 6e 73 20 | 74 68 65 20 6f 72 69 67 |ontains |the orig| |00002dc0| 69 6e 61 6c 20 68 61 6e | 64 6c 65 20 73 74 61 74 |inal han|dle stat| |00002dd0| 65 20 28 64 65 72 69 76 | 65 64 20 76 69 61 20 61 |e (deriv|ed via a| |00002de0| 20 63 61 6c 6c 20 74 6f | 20 53 48 47 65 74 53 74 | call to| SHGetSt| |00002df0| 61 74 65 29 2c 20 73 6f | 20 48 65 6c 70 65 72 20 |ate), so| Helper | |00002e00| 63 61 6e 20 72 65 73 65 | 74 20 74 68 65 20 68 61 |can rese|t the ha| |00002e10| 6e 64 6c 65 d5 73 20 73 | 74 61 74 65 20 61 66 74 |ndle.s s|tate aft| |00002e20| 65 72 20 70 6c 61 79 62 | 61 63 6b 20 69 73 20 63 |er playb|ack is c| |00002e30| 6f 6d 70 6c 65 74 65 2e | 20 54 68 65 20 69 6e 55 |omplete.| The inU| |00002e40| 73 65 20 66 69 65 6c 64 | 20 74 65 6c 6c 73 20 77 |se field| tells w| |00002e50| 68 65 74 68 65 72 20 61 | 20 67 69 76 65 6e 20 53 |hether a| given S| |00002e60| 48 4f 75 74 52 65 63 20 | 69 73 20 69 6e 20 75 73 |HOutRec |is in us| |00002e70| 65 20 62 79 20 61 20 70 | 6c 61 79 69 6e 67 20 73 |e by a p|laying s| |00002e80| 6f 75 6e 64 20 28 61 73 | 20 6f 70 70 6f 73 65 64 |ound (as| opposed| |00002e90| 20 74 6f 20 61 76 61 69 | 6c 61 62 6c 65 20 66 6f | to avai|lable fo| |00002ea0| 72 20 72 65 75 73 65 29 | 2e 20 46 69 6e 61 6c 6c |r reuse)|. Finall| |00002eb0| 79 2c 20 74 68 65 20 70 | 61 75 73 65 64 20 66 6c |y, the p|aused fl| |00002ec0| 61 67 20 6c 65 74 73 20 | 48 65 6c 70 65 72 20 72 |ag lets |Helper r| |00002ed0| 65 6d 65 6d 62 65 72 20 | 77 68 65 6e 20 61 20 73 |emember |when a s| |00002ee0| 6f 75 6e 64 20 68 61 73 | 20 62 65 65 6e 20 70 61 |ound has| been pa| |00002ef0| 75 73 65 64 2e 0d 74 79 | 70 65 64 65 66 20 73 74 |used..ty|pedef st| |00002f00| 72 75 63 74 20 7b 0d 09 | 6c 6f 6e 67 09 69 6e 52 |ruct {..|long.inR| |00002f10| 65 66 4e 75 6d 3b 09 2f | 2f 20 53 6f 75 6e 64 20 |efNum;./|/ Sound | |00002f20| 4d 61 6e 61 67 65 72 27 | 73 20 69 6e 70 75 74 20 |Manager'|s input | |00002f30| 64 65 76 69 63 65 20 72 | 65 66 4e 75 6d 2e 0d 09 |device r|efNum...| |00002f40| 53 50 42 09 69 6e 50 42 | 3b 09 2f 2f 20 54 68 65 |SPB.inPB|;.// The| |00002f50| 20 69 6e 70 75 74 20 70 | 61 72 61 6d 65 74 65 72 | input p|arameter| |00002f60| 20 62 6c 6f 63 6b 2e 0d | 09 48 61 6e 64 6c 65 09 | block..|.Handle.| |00002f70| 69 6e 48 61 6e 64 6c 65 | 3b 09 2f 2f 20 54 68 65 |inHandle|;.// The| |00002f80| 20 68 61 6e 64 6c 65 20 | 77 65 27 72 65 20 72 65 | handle |we're re| |00002f90| 63 6f 72 64 69 6e 67 20 | 69 6e 74 6f 2e 0d 09 73 |cording |into...s| |00002fa0| 68 6f 72 74 09 68 65 61 | 64 65 72 4c 65 6e 67 74 |hort.hea|derLengt| |00002fb0| 68 3b 09 2f 2f 20 54 68 | 65 20 6c 65 6e 67 74 68 |h;.// Th|e length| |00002fc0| 20 6f 66 20 74 68 65 20 | 73 6f 75 6e 64 27 73 20 | of the |sound's | |00002fd0| 68 65 61 64 65 72 2e 0d | 09 42 6f 6f 6c 65 61 6e |header..|.Boolean| |00002fe0| 09 72 65 63 6f 72 64 69 | 6e 67 3b 09 2f 2f 20 54 |.recordi|ng;.// T| |00002ff0| 65 6c 6c 73 20 74 68 61 | 74 20 77 65 27 72 65 20 |ells tha|t we're | |00003000| 61 63 74 75 61 6c 6c 79 | 20 72 65 63 6f 72 64 69 |actually| recordi| |00003010| 6e 67 2e 0d 09 42 6f 6f | 6c 65 61 6e 09 72 65 63 |ng...Boo|lean.rec| |00003020| 6f 72 64 43 6f 6d 70 6c | 65 74 65 3b 09 2f 2f 20 |ordCompl|ete;.// | |00003030| 54 65 6c 6c 73 20 74 68 | 61 74 20 72 65 63 6f 72 |Tells th|at recor| |00003040| 64 69 6e 67 20 69 73 20 | 63 6f 6d 70 6c 65 74 65 |ding is |complete| |00003050| 2e 0d 09 4f 53 45 72 72 | 09 72 65 63 6f 72 64 45 |...OSErr|.recordE| |00003060| 72 72 3b 09 2f 2f 20 45 | 72 72 6f 72 2c 20 69 66 |rr;.// E|rror, if| |00003070| 20 65 72 72 6f 72 20 74 | 65 72 6d 69 6e 61 74 65 | error t|erminate| |00003080| 64 20 72 65 63 6f 72 64 | 69 6e 67 2e 0d 09 73 68 |d record|ing...sh| |00003090| 6f 72 74 09 6e 75 6d 43 | 68 61 6e 6e 65 6c 73 3b |ort.numC|hannels;| |000030a0| 09 2f 2f 20 4e 75 6d 62 | 65 72 20 6f 66 20 63 68 |.// Numb|er of ch| |000030b0| 61 6e 6e 65 6c 73 20 66 | 6f 72 20 72 65 63 6f 72 |annels f|or recor| |000030c0| 64 69 6e 67 2e 0d 09 73 | 68 6f 72 74 09 73 61 6d |ding...s|hort.sam| |000030d0| 70 6c 65 53 69 7a 65 3b | 09 2f 2f 20 53 61 6d 70 |pleSize;|.// Samp| |000030e0| 6c 65 20 73 69 7a 65 20 | 66 6f 72 20 72 65 63 6f |le size |for reco| |000030f0| 72 64 69 6e 67 2e 0d 09 | 46 69 78 65 64 09 73 61 |rding...|Fixed.sa| |00003100| 6d 70 6c 65 52 61 74 65 | 3b 09 2f 2f 20 53 61 6d |mpleRate|;.// Sam| |00003110| 70 6c 65 20 72 61 74 65 | 20 66 6f 72 20 72 65 63 |ple rate| for rec| |00003120| 6f 72 64 69 6e 67 2e 0d | 09 4f 53 54 79 70 65 09 |ording..|.OSType.| |00003130| 63 6f 6d 70 54 79 70 65 | 3b 09 2f 2f 20 43 6f 6d |compType|;.// Com| |00003140| 70 72 65 73 73 69 6f 6e | 20 74 79 70 65 20 66 6f |pression| type fo| |00003150| 72 20 72 65 63 6f 72 64 | 69 6e 67 2e 0d 09 42 6f |r record|ing...Bo| |00003160| 6f 6c 65 61 6e 09 2a 61 | 70 70 43 6f 6d 70 6c 65 |olean.*a|ppComple| |00003170| 74 65 3b 09 2f 2f 20 54 | 65 6c 6c 73 20 63 61 6c |te;.// T|ells cal| |00003180| 6c 65 72 20 77 68 65 6e | 20 72 65 63 6f 72 64 69 |ler when| recordi| |00003190| 6e 67 20 69 73 20 64 6f | 6e 65 2e 0d 09 42 6f 6f |ng is do|ne...Boo| |000031a0| 6c 65 61 6e 09 70 61 75 | 73 65 64 3b 09 2f 2f 20 |lean.pau|sed;.// | |000031b0| 54 65 6c 6c 73 20 74 68 | 61 74 20 72 65 63 6f 72 |Tells th|at recor| |000031c0| 64 69 6e 67 20 68 61 73 | 20 62 65 65 6e 20 70 61 |ding has| been pa| |000031d0| 75 73 65 64 2e 0d 7d 20 | 53 48 49 6e 70 75 74 56 |used..} |SHInputV| |000031e0| 61 72 73 3b 0d 54 68 65 | 20 53 48 49 6e 70 75 74 |ars;.The| SHInput| |000031f0| 56 61 72 73 20 72 65 63 | 6f 72 64 20 63 6f 6e 74 |Vars rec|ord cont| |00003200| 61 69 6e 73 20 69 6e 66 | 6f 72 6d 61 74 69 6f 6e |ains inf|ormation| |00003210| 20 70 65 72 74 61 69 6e | 69 6e 67 20 74 6f 20 61 | pertain|ing to a| |00003220| 20 73 6f 75 6e 64 20 62 | 65 69 6e 67 20 72 65 63 | sound b|eing rec| |00003230| 6f 72 64 65 64 2e 20 57 | 68 65 6e 20 74 68 65 20 |orded. W|hen the | |00003240| 73 6f 75 6e 64 20 69 6e | 70 75 74 20 64 65 76 69 |sound in|put devi| |00003250| 63 65 20 69 73 20 6f 70 | 65 6e 65 64 2c 20 69 74 |ce is op|ened, it| |00003260| 73 20 72 65 66 65 72 65 | 6e 63 65 20 6e 75 6d 62 |s refere|nce numb| |00003270| 65 72 20 69 73 20 73 74 | 6f 72 65 64 20 69 6e 20 |er is st|ored in | |00003280| 69 6e 52 65 66 4e 75 6d | 2e 20 54 68 65 20 73 6f |inRefNum|. The so| |00003290| 75 6e 64 20 69 6e 70 75 | 74 20 70 61 72 61 6d 65 |und inpu|t parame| |000032a0| 74 65 72 20 62 6c 6f 63 | 6b 2c 20 69 6e 50 42 2c |ter bloc|k, inPB,| |000032b0| 20 69 73 20 70 61 72 74 | 20 6f 66 20 53 48 49 6e | is part| of SHIn| |000032c0| 70 75 74 56 61 72 73 2e | 20 54 68 65 20 73 6f 75 |putVars.| The sou| |000032d0| 6e 64 20 62 65 69 6e 67 | 20 72 65 63 6f 72 64 65 |nd being| recorde| |000032e0| 64 20 69 73 20 73 74 6f | 72 65 64 20 69 6e 20 69 |d is sto|red in i| |000032f0| 6e 48 61 6e 64 6c 65 20 | 75 6e 74 69 6c 20 63 6f |nHandle |until co| |00003300| 6d 70 6c 65 74 65 2e 20 | 54 68 65 20 72 65 63 6f |mplete. |The reco| |00003310| 72 64 69 6e 67 20 66 6c | 61 67 20 74 65 6c 6c 73 |rding fl|ag tells| |00003320| 20 77 68 65 74 68 65 72 | 20 77 65 d5 72 65 20 61 | whether| we.re a| |00003330| 63 74 75 61 6c 6c 79 20 | 69 6e 20 74 68 65 20 61 |ctually |in the a| |00003340| 63 74 20 6f 66 20 61 73 | 79 6e 63 68 72 6f 6e 6f |ct of as|ynchrono| |00003350| 75 73 20 72 65 63 6f 72 | 64 69 6e 67 2c 20 61 6e |us recor|ding, an| |00003360| 64 20 74 68 65 20 72 65 | 63 6f 72 64 43 6f 6d 70 |d the re|cordComp| |00003370| 6c 65 74 65 20 66 6c 61 | 67 20 28 73 65 74 20 62 |lete fla|g (set b| |00003380| 79 20 74 68 65 20 72 65 | 63 6f 72 64 20 63 6f 6d |y the re|cord com| |00003390| 70 6c 65 74 69 6f 6e 20 | 72 6f 75 74 69 6e 65 2c |pletion |routine,| |000033a0| 20 64 65 73 63 72 69 62 | 65 64 20 6c 61 74 65 72 | describ|ed later| |000033b0| 29 20 74 65 6c 6c 73 20 | 75 73 20 77 68 65 6e 20 |) tells |us when | |000033c0| 72 65 63 6f 72 64 69 6e | 67 20 68 61 73 20 63 6f |recordin|g has co| |000033d0| 6d 70 6c 65 74 65 64 2e | 20 49 66 20 61 6e 20 65 |mpleted.| If an e| |000033e0| 72 72 6f 72 20 6f 63 63 | 75 72 73 20 64 75 72 69 |rror occ|urs duri| |000033f0| 6e 67 20 72 65 63 6f 72 | 64 69 6e 67 2c 20 69 74 |ng recor|ding, it| |00003400| d5 73 20 73 61 76 65 64 | 20 69 6e 20 72 65 63 6f |.s saved| in reco| |00003410| 72 64 45 72 72 20 73 6f | 20 74 68 61 74 20 69 74 |rdErr so| that it| |00003420| 20 63 61 6e 20 62 65 20 | 72 65 74 75 72 6e 65 64 | can be |returned| |00003430| 20 74 6f 20 74 68 65 20 | 61 70 70 6c 69 63 61 74 | to the |applicat| |00003440| 69 6f 6e 20 6c 61 74 65 | 72 2c 20 77 68 65 6e 20 |ion late|r, when | |00003450| 69 74 20 63 61 6c 6c 73 | 20 53 48 47 65 74 52 65 |it calls| SHGetRe| |00003460| 63 6f 72 64 65 64 53 6f | 75 6e 64 2e 20 54 68 65 |cordedSo|und. The| |00003470| 20 6e 65 78 74 20 66 6f | 75 72 20 66 69 65 6c 64 | next fo|ur field| |00003480| 73 d1 6e 75 6d 43 68 61 | 6e 6e 65 6c 73 2c 20 73 |s.numCha|nnels, s| |00003490| 61 6d 70 6c 65 53 69 7a | 65 2c 20 73 61 6d 70 6c |ampleSiz|e, sampl| |000034a0| 65 52 61 74 65 2c 20 61 | 6e 64 20 63 6f 6d 70 54 |eRate, a|nd compT| |000034b0| 79 70 65 d1 68 6f 6c 64 | 20 69 6e 66 6f 72 6d 61 |ype.hold| informa| |000034c0| 74 69 6f 6e 20 74 68 61 | 74 d5 73 20 75 73 65 64 |tion tha|t.s used| |000034d0| 20 74 6f 20 63 6f 6e 73 | 74 72 75 63 74 20 74 68 | to cons|truct th| |000034e0| 65 20 73 6f 75 6e 64 d5 | 73 20 68 65 61 64 65 72 |e sound.|s header| |000034f0| 2e 20 54 68 65 20 61 70 | 70 43 6f 6d 70 6c 65 74 |. The ap|pComplet| |00003500| 65 20 66 69 65 6c 64 20 | 70 6f 69 6e 74 73 20 74 |e field |points t| |00003510| 6f 20 61 20 42 6f 6f 6c | 65 61 6e 20 74 68 61 74 |o a Bool|ean that| |00003520| 20 74 68 65 20 61 70 70 | 6c 69 63 61 74 69 6f 6e | the app|lication| |00003530| 20 6d 61 79 20 6f 70 74 | 69 6f 6e 61 6c 6c 79 20 | may opt|ionally | |00003540| 75 73 65 20 74 6f 20 62 | 65 20 69 6e 66 6f 72 6d |use to b|e inform| |00003550| 65 64 20 6f 66 20 72 65 | 63 6f 72 64 69 6e 67 20 |ed of re|cording | |00003560| 74 65 72 6d 69 6e 61 74 | 69 6f 6e 20 28 74 68 65 |terminat|ion (the| |00003570| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 6d 61 79 | applica|tion may| |00003580| 20 75 73 65 20 72 65 70 | 65 61 74 65 64 20 63 61 | use rep|eated ca| |00003590| 6c 6c 73 20 74 6f 20 74 | 68 65 20 53 48 52 65 63 |lls to t|he SHRec| |000035a0| 6f 72 64 53 74 61 74 75 | 73 20 72 6f 75 74 69 6e |ordStatu|s routin| |000035b0| 65 20 69 6e 73 74 65 61 | 64 29 2e 20 54 68 65 20 |e instea|d). The | |000035c0| 70 61 75 73 65 64 20 66 | 6c 61 67 20 6c 65 74 73 |paused f|lag lets| |000035d0| 20 48 65 6c 70 65 72 20 | 6b 65 65 70 20 74 72 61 | Helper |keep tra| |000035e0| 63 6b 20 6f 66 20 77 68 | 65 6e 20 72 65 63 6f 72 |ck of wh|en recor| |000035f0| 64 69 6e 67 20 68 61 73 | 20 62 65 65 6e 20 70 61 |ding has| been pa| |00003600| 75 73 65 64 2e 0d 48 65 | 6c 70 65 72 20 64 65 63 |used..He|lper dec| |00003610| 6c 61 72 65 73 20 69 74 | 73 20 67 6c 6f 62 61 6c |lares it|s global| |00003620| 20 73 74 6f 72 61 67 65 | 20 61 73 20 73 68 6f 77 | storage| as show| |00003630| 6e 20 6f 6e 20 74 68 65 | 20 66 6f 6c 6c 6f 77 69 |n on the| followi| |00003640| 6e 67 20 70 61 67 65 2e | 20 41 73 20 77 65 20 67 |ng page.| As we g| |00003650| 6f 20 6f 6e 2c 20 79 6f | 75 d5 6c 6c 20 73 65 65 |o on, yo|u.ll see| |00003660| 20 74 68 65 20 75 73 65 | 20 6f 66 20 74 68 65 73 | the use| of thes| |00003670| 65 20 67 6c 6f 62 61 6c | 73 20 69 6e 20 63 6f 6e |e global|s in con| |00003680| 74 65 78 74 2c 20 77 68 | 69 63 68 20 77 69 6c 6c |text, wh|ich will| |00003690| 20 63 6c 61 72 69 66 79 | 20 74 68 65 69 72 20 66 | clarify| their f| |000036a0| 75 6e 63 74 69 6f 6e 2e | 0d 0d 73 74 61 74 69 63 |unction.|..static| |000036b0| 20 42 6f 6f 6c 65 61 6e | 09 67 73 53 48 49 6e 69 | Boolean|.gsSHIni| |000036c0| 74 65 64 20 3d 20 66 61 | 6c 73 65 3b 09 2f 2f 20 |ted = fa|lse;.// | |000036d0| 48 61 73 20 48 65 6c 70 | 65 72 20 62 65 65 6e 20 |Has Help|er been | |000036e0| 69 6e 69 74 69 61 6c 69 | 7a 65 64 3f 0d 73 74 61 |initiali|zed?.sta| |000036f0| 74 69 63 20 42 6f 6f 6c | 65 61 6e 09 2a 67 73 53 |tic Bool|ean.*gsS| |00003700| 48 4e 65 65 64 73 54 69 | 6d 65 3b 09 2f 2f 20 50 |HNeedsTi|me;.// P| |00003710| 6f 69 6e 74 65 72 20 74 | 6f 20 61 70 70 6c 69 63 |ointer t|o applic| |00003720| 61 74 69 6f 6e 27 73 0d | 09 09 2f 2f 20 61 74 74 |ation's.|..// att| |00003730| 65 6e 74 69 6f 6e 20 66 | 6c 61 67 2e 0d 73 74 61 |ention f|lag..sta| |00003740| 74 69 63 20 53 48 4f 75 | 74 70 75 74 56 61 72 73 |tic SHOu|tputVars| |00003750| 09 67 73 53 48 4f 75 74 | 56 61 72 73 3b 09 2f 2f |.gsSHOut|Vars;.//| |00003760| 20 53 6f 75 6e 64 20 6f | 75 74 70 75 74 20 76 61 | Sound o|utput va| |00003770| 72 69 61 62 6c 65 73 2e | 0d 73 74 61 74 69 63 20 |riables.|.static | |00003780| 53 48 49 6e 70 75 74 56 | 61 72 73 09 67 73 53 48 |SHInputV|ars.gsSH| |00003790| 49 6e 56 61 72 73 3b 09 | 2f 2f 20 53 6f 75 6e 64 |InVars;.|// Sound| |000037a0| 20 69 6e 70 75 74 20 76 | 61 72 69 61 62 6c 65 73 | input v|ariables| |000037b0| 2e 0d 48 45 4c 50 45 52 | 27 53 20 49 4e 54 45 52 |..HELPER|'S INTER| |000037c0| 4e 41 4c 20 55 54 49 4c | 49 54 59 20 52 4f 55 54 |NAL UTIL|ITY ROUT| |000037d0| 49 4e 45 53 0d 48 65 6c | 70 65 72 20 75 73 65 73 |INES.Hel|per uses| |000037e0| 20 74 77 65 6c 76 65 20 | 73 74 61 74 69 63 20 75 | twelve |static u| |000037f0| 74 69 6c 69 74 79 20 72 | 6f 75 74 69 6e 65 73 20 |tility r|outines | |00003800| 74 6f 20 68 65 6c 70 20 | 69 74 20 63 61 72 72 79 |to help |it carry| |00003810| 20 6f 75 74 20 69 74 73 | 20 6a 6f 62 2e 20 4d 61 | out its| job. Ma| |00003820| 6e 79 20 6f 66 20 74 68 | 65 73 65 20 72 6f 75 74 |ny of th|ese rout| |00003830| 69 6e 65 73 20 61 72 65 | 20 74 72 69 76 69 61 6c |ines are| trivial| |00003840| 2c 20 62 75 74 20 6c 65 | 74 d5 73 20 67 6f 20 6f |, but le|t.s go o| |00003850| 76 65 72 20 61 20 66 65 | 77 20 6f 66 20 74 68 65 |ver a fe|w of the| |00003860| 20 6d 6f 72 65 20 69 6d | 70 6f 72 74 61 6e 74 20 | more im|portant | |00003870| 6f 6e 65 73 20 69 6e 20 | 64 65 74 61 69 6c d1 20 |ones in |detail. | |00003880| 53 48 50 6c 61 79 43 6f | 6d 70 6c 65 74 69 6f 6e |SHPlayCo|mpletion| |00003890| 2c 20 53 48 52 65 63 6f | 72 64 43 6f 6d 70 6c 65 |, SHReco|rdComple| |000038a0| 74 69 6f 6e 2c 20 61 6e | 64 20 53 48 4f 75 74 52 |tion, an|d SHOutR| |000038b0| 65 63 46 72 6f 6d 52 65 | 66 4e 75 6d 2e 0d 57 68 |ecFromRe|fNum..Wh| |000038c0| 65 6e 20 48 65 6c 70 65 | 72 20 70 65 72 66 6f 72 |en Helpe|r perfor| |000038d0| 6d 73 20 61 73 79 6e 63 | 68 72 6f 6e 6f 75 73 20 |ms async|hronous | |000038e0| 73 6f 75 6e 64 20 70 6c | 61 79 62 61 63 6b 2c 20 |sound pl|ayback, | |000038f0| 69 74 20 64 65 70 65 6e | 64 73 20 6f 6e 20 61 20 |it depen|ds on a | |00003900| 63 61 6c 6c 62 61 63 6b | 20 72 6f 75 74 69 6e 65 |callback| routine| |00003910| 20 74 68 61 74 20 73 69 | 67 6e 61 6c 73 20 74 6f | that si|gnals to| |00003920| 20 74 68 65 20 61 70 70 | 6c 69 63 61 74 69 6f 6e | the app|lication| |00003930| 20 74 68 61 74 20 70 6c | 61 79 62 61 63 6b 20 68 | that pl|ayback h| |00003940| 61 73 20 63 6f 6d 70 6c | 65 74 65 64 2e 20 48 65 |as compl|eted. He| |00003950| 72 65 d5 73 20 74 68 65 | 20 70 6c 61 79 62 61 63 |re.s the| playbac| |00003960| 6b 20 63 61 6c 6c 62 61 | 63 6b 20 72 6f 75 74 69 |k callba|ck routi| |00003970| 6e 65 2c 20 53 48 50 6c | 61 79 43 6f 6d 70 6c 65 |ne, SHPl|ayComple| |00003980| 74 69 6f 6e 3a 0d 70 61 | 73 63 61 6c 20 76 6f 69 |tion:.pa|scal voi| |00003990| 64 20 53 48 50 6c 61 79 | 43 6f 6d 70 6c 65 74 69 |d SHPlay|Completi| |000039a0| 6f 6e 28 53 6e 64 43 68 | 61 6e 6e 65 6c 50 74 72 |on(SndCh|annelPtr| |000039b0| 20 63 68 61 6e 6e 65 6c | 2c 20 53 6e 64 43 6f 6d | channel|, SndCom| |000039c0| 6d 61 6e 64 20 2a 63 6f | 6d 6d 61 6e 64 29 0d 7b |mand *co|mmand).{| |000039d0| 0d 09 6c 6f 6e 67 09 6f | 74 68 65 72 41 35 3b 0d |..long.o|therA5;.| |000039e0| 09 0d 09 2f 2f 20 4c 6f | 6f 6b 20 66 6f 72 20 6f |...// Lo|ok for o| |000039f0| 75 72 20 22 63 61 6c 6c | 62 61 63 6b 20 73 69 67 |ur "call|back sig| |00003a00| 6e 61 74 75 72 65 22 20 | 69 6e 20 74 68 65 20 73 |nature" |in the s| |00003a10| 6f 75 6e 64 20 63 6f 6d | 6d 61 6e 64 2e 0d 09 69 |ound com|mand...i| |00003a20| 66 20 28 63 6f 6d 6d 61 | 6e 64 2d 3e 70 61 72 61 |f (comma|nd->para| |00003a30| 6d 31 20 3d 3d 20 6b 53 | 48 43 6f 6d 70 6c 65 74 |m1 == kS|HComplet| |00003a40| 65 53 69 67 29 20 7b 0d | 09 09 6f 74 68 65 72 41 |eSig) {.|..otherA| |00003a50| 35 20 3d 20 53 65 74 41 | 35 28 63 6f 6d 6d 61 6e |5 = SetA|5(comman| |00003a60| 64 2d 3e 70 61 72 61 6d | 32 29 3b 09 2f 2f 20 53 |d->param|2);.// S| |00003a70| 65 74 20 75 70 20 6f 75 | 72 20 41 35 2e 0d 09 09 |et up ou|r A5....| |00003a80| 0d 09 09 63 68 61 6e 6e | 65 6c 2d 3e 75 73 65 72 |...chann|el->user| |00003a90| 49 6e 66 6f 20 3d 20 6b | 53 48 43 6f 6d 70 6c 65 |Info = k|SHComple| |00003aa0| 74 65 3b 0d 09 09 2a 67 | 73 53 48 4e 65 65 64 73 |te;...*g|sSHNeeds| |00003ab0| 54 69 6d 65 20 3d 20 74 | 72 75 65 3b 09 09 09 09 |Time = t|rue;....| |00003ac0| 2f 2f 20 54 65 6c 6c 20 | 61 70 70 6c 69 63 61 74 |// Tell |applicat| |00003ad0| 69 6f 6e 20 74 6f 20 67 | 69 76 65 20 75 73 20 0d |ion to g|ive us .| |00003ae0| 09 09 09 09 09 09 09 09 | 09 09 09 2f 2f 20 61 6e |........|...// an| |00003af0| 20 53 48 49 64 6c 65 20 | 63 61 6c 6c 2e 0d 09 09 | SHIdle |call....| |00003b00| 0d 09 09 53 65 74 41 35 | 28 6f 74 68 65 72 41 35 |...SetA5|(otherA5| |00003b10| 29 3b 09 09 09 09 09 2f | 2f 20 52 65 73 74 6f 72 |);...../|/ Restor| |00003b20| 65 20 6f 6c 64 20 41 35 | 2e 0d 09 7d 0d 7d 0d 57 |e old A5|...}.}.W| |00003b30| 68 65 6e 20 48 65 6c 70 | 65 72 20 62 65 67 69 6e |hen Help|er begin| |00003b40| 73 20 74 68 65 20 73 6f | 75 6e 64 20 70 6c 61 79 |s the so|und play| |00003b50| 62 61 63 6b 2c 20 69 74 | 20 71 75 65 75 65 73 20 |back, it| queues | |00003b60| 75 70 20 61 20 73 6f 75 | 6e 64 20 63 6f 6d 6d 61 |up a sou|nd comma| |00003b70| 6e 64 d1 61 20 63 61 6c | 6c 42 61 63 6b 43 6d 64 |nd.a cal|lBackCmd| |00003b80| d1 69 6e 20 74 68 65 20 | 73 6f 75 6e 64 20 63 68 |.in the |sound ch| |00003b90| 61 6e 6e 65 6c 2e 20 54 | 68 65 20 63 61 6c 6c 42 |annel. T|he callB| |00003ba0| 61 63 6b 43 6d 64 20 74 | 65 6c 6c 73 20 74 68 65 |ackCmd t|ells the| |00003bb0| 20 53 6f 75 6e 64 20 4d | 61 6e 61 67 65 72 20 74 | Sound M|anager t| |00003bc0| 6f 20 63 61 6c 6c 20 74 | 68 65 20 63 61 6c 6c 62 |o call t|he callb| |00003bd0| 61 63 6b 20 72 6f 75 74 | 69 6e 65 2c 20 53 48 50 |ack rout|ine, SHP| |00003be0| 6c 61 79 43 6f 6d 70 6c | 65 74 69 6f 6e 2e 20 57 |layCompl|etion. W| |00003bf0| 65 20 70 6c 61 63 65 20 | 61 20 76 65 72 69 66 69 |e place |a verifi| |00003c00| 61 62 6c 65 20 d2 73 69 | 67 6e 61 74 75 72 65 d3 |able .si|gnature.| |00003c10| 20 69 6e 20 74 68 65 20 | 73 6f 75 6e 64 20 63 6f | in the |sound co| |00003c20| 6d 6d 61 6e 64 20 72 65 | 63 6f 72 64 20 73 6f 20 |mmand re|cord so | |00003c30| 74 68 61 74 20 74 68 65 | 20 61 70 70 6c 69 63 61 |that the| applica| |00003c40| 74 69 6f 6e 20 63 61 6e | 20 76 65 72 69 66 79 20 |tion can| verify | |00003c50| 74 68 61 74 20 74 68 65 | 20 63 61 6c 6c 20 6f 63 |that the| call oc| |00003c60| 63 75 72 72 65 64 20 61 | 73 20 61 20 72 65 73 75 |curred a|s a resu| |00003c70| 6c 74 20 6f 66 20 61 20 | 73 70 65 63 69 66 69 63 |lt of a |specific| |00003c80| 20 63 61 6c 6c 42 61 63 | 6b 43 6d 64 2c 20 61 6e | callBac|kCmd, an| |00003c90| 64 20 6e 6f 74 20 61 73 | 20 61 20 72 65 73 75 6c |d not as| a resul| |00003ca0| 74 20 6f 66 20 73 6f 6d | 65 20 73 70 75 72 69 6f |t of som|e spurio| |00003cb0| 75 73 20 6f 6e 65 2e 20 | 57 68 65 6e 20 73 75 63 |us one. |When suc| |00003cc0| 68 20 61 20 62 6c 65 73 | 73 65 64 20 63 61 6c 6c |h a bles|sed call| |00003cd0| 62 61 63 6b 20 6f 63 63 | 75 72 73 2c 20 48 65 6c |back occ|urs, Hel| |00003ce0| 70 65 72 20 75 73 65 73 | 20 61 6e 6f 74 68 65 72 |per uses| another| |00003cf0| 20 68 61 6e 64 79 20 76 | 61 6c 75 65 20 73 74 75 | handy v|alue stu| |00003d00| 66 66 65 64 20 69 6e 74 | 6f 20 74 68 65 20 73 6f |ffed int|o the so| |00003d10| 75 6e 64 20 63 6f 6d 6d | 61 6e 64 d1 61 20 70 6f |und comm|and.a po| |00003d20| 69 6e 74 65 72 20 74 6f | 20 74 68 65 20 41 35 20 |inter to| the A5 | |00003d30| 67 6c 6f 62 61 6c 20 77 | 6f 72 6c 64 d1 74 6f 20 |global w|orld.to | |00003d40| 73 65 74 20 75 70 20 61 | 63 63 65 73 73 20 74 6f |set up a|ccess to| |00003d50| 20 74 68 65 20 67 6c 6f | 62 61 6c 73 2e 20 48 65 | the glo|bals. He| |00003d60| 6c 70 65 72 20 74 68 65 | 6e 20 73 65 74 73 20 74 |lper the|n sets t| |00003d70| 68 65 20 63 68 61 6e 6e | 65 6c d5 73 20 75 73 65 |he chann|el.s use| |00003d80| 72 49 6e 66 6f 20 66 69 | 65 6c 64 20 74 6f 20 61 |rInfo fi|eld to a| |00003d90| 20 76 61 6c 75 65 20 74 | 68 61 74 20 66 6c 61 67 | value t|hat flag| |00003da0| 73 20 74 68 65 20 73 6f | 75 6e 64 20 61 73 20 63 |s the so|und as c| |00003db0| 6f 6d 70 6c 65 74 65 2e | 20 48 65 6c 70 65 72 20 |omplete.| Helper | |00003dc0| 61 6c 73 6f 20 73 65 74 | 73 20 74 68 65 20 61 70 |also set|s the ap| |00003dd0| 70 6c 69 63 61 74 69 6f | 6e d5 73 20 61 74 74 65 |plicatio|n.s atte| |00003de0| 6e 74 69 6f 6e 20 66 6c | 61 67 20 73 6f 20 74 68 |ntion fl|ag so th| |00003df0| 61 74 20 6c 61 74 65 72 | 2c 20 69 6e 20 74 68 65 |at later|, in the| |00003e00| 20 6d 61 69 6e 20 65 76 | 65 6e 74 20 6c 6f 6f 70 | main ev|ent loop| |00003e10| 2c 20 74 68 65 20 61 70 | 70 6c 69 63 61 74 69 6f |, the ap|plicatio| |00003e20| 6e 20 73 65 65 73 20 74 | 68 61 74 20 74 68 65 20 |n sees t|hat the | |00003e30| 61 74 74 65 6e 74 69 6f | 6e 20 66 6c 61 67 20 69 |attentio|n flag i| |00003e40| 73 20 73 65 74 20 61 6e | 64 20 63 61 6c 6c 73 20 |s set an|d calls | |00003e50| 53 48 49 64 6c 65 2e 20 | 53 48 49 64 6c 65 20 74 |SHIdle. |SHIdle t| |00003e60| 68 65 6e 20 73 6b 69 70 | 73 20 74 68 72 6f 75 67 |hen skip|s throug| |00003e70| 68 20 74 68 65 20 53 48 | 4f 75 74 52 65 63 20 61 |h the SH|OutRec a| |00003e80| 72 72 61 79 20 6c 6f 6f | 6b 69 6e 67 20 66 6f 72 |rray loo|king for| |00003e90| 20 73 6f 75 6e 64 20 63 | 68 61 6e 6e 65 6c 73 20 | sound c|hannels | |00003ea0| 74 68 61 74 20 61 72 65 | 20 69 6e 20 75 73 65 20 |that are| in use | |00003eb0| 61 6e 64 20 68 61 76 65 | 20 6b 53 48 43 6f 6d 70 |and have| kSHComp| |00003ec0| 6c 65 74 65 20 69 6e 20 | 74 68 65 69 72 20 75 73 |lete in |their us| |00003ed0| 65 72 49 6e 66 6f 20 66 | 69 65 6c 64 73 2c 20 61 |erInfo f|ields, a| |00003ee0| 6e 64 20 64 69 73 70 6f | 73 65 73 20 6f 66 20 74 |nd dispo|ses of t| |00003ef0| 68 65 69 72 20 73 6f 75 | 6e 64 20 63 68 61 6e 6e |heir sou|nd chann| |00003f00| 65 6c 73 2e 20 54 68 69 | 73 20 69 73 20 68 6f 77 |els. Thi|s is how| |00003f10| 20 48 65 6c 70 65 72 20 | 63 6c 65 61 6e 73 20 75 | Helper |cleans u| |00003f20| 70 20 61 66 74 65 72 20 | 73 6f 75 6e 64 20 70 6c |p after |sound pl| |00003f30| 61 79 62 61 63 6b 20 68 | 61 73 20 63 6f 6d 70 6c |ayback h|as compl| |00003f40| 65 74 65 64 2e 0d 41 73 | 79 6e 63 68 72 6f 6e 6f |eted..As|ynchrono| |00003f50| 75 73 20 73 6f 75 6e 64 | 20 72 65 63 6f 72 64 69 |us sound| recordi| |00003f60| 6e 67 20 61 6c 73 6f 20 | 72 65 6c 69 65 73 20 6f |ng also |relies o| |00003f70| 6e 20 61 20 63 61 6c 6c | 62 61 63 6b 20 72 6f 75 |n a call|back rou| |00003f80| 74 69 6e 65 20 74 68 61 | 74 20 73 69 67 6e 61 6c |tine tha|t signal| |00003f90| 73 20 77 68 65 6e 20 72 | 65 63 6f 72 64 69 6e 67 |s when r|ecording| |00003fa0| 20 68 61 73 20 63 6f 6d | 70 6c 65 74 65 64 2e 20 | has com|pleted. | |00003fb0| 48 65 72 65 d5 73 20 74 | 68 65 20 63 61 6c 6c 62 |Here.s t|he callb| |00003fc0| 61 63 6b 20 72 6f 75 74 | 69 6e 65 2c 20 53 48 52 |ack rout|ine, SHR| |00003fd0| 65 63 6f 72 64 43 6f 6d | 70 6c 65 74 69 6f 6e 3a |ecordCom|pletion:| |00003fe0| 0d 70 61 73 63 61 6c 20 | 76 6f 69 64 20 53 48 52 |.pascal |void SHR| |00003ff0| 65 63 6f 72 64 43 6f 6d | 70 6c 65 74 69 6f 6e 28 |ecordCom|pletion(| |00004000| 53 50 42 50 74 72 20 69 | 6e 50 61 72 61 6d 73 29 |SPBPtr i|nParams)| |00004010| 0d 7b 0d 09 6c 6f 6e 67 | 09 6f 74 68 65 72 41 35 |.{..long|.otherA5| |00004020| 3b 0d 09 0d 09 6f 74 68 | 65 72 41 35 20 3d 20 53 |;....oth|erA5 = S| |00004030| 65 74 41 35 28 69 6e 50 | 61 72 61 6d 73 2d 3e 75 |etA5(inP|arams->u| |00004040| 73 65 72 4c 6f 6e 67 29 | 3b 09 2f 2f 20 53 65 74 |serLong)|;.// Set| |00004050| 20 75 70 20 6f 75 72 20 | 41 35 2e 0d 09 2a 67 73 | up our |A5...*gs| |00004060| 53 48 4e 65 65 64 73 54 | 69 6d 65 20 3d 20 74 72 |SHNeedsT|ime = tr| |00004070| 75 65 3b 09 09 09 09 09 | 09 2f 2f 20 54 65 6c 6c |ue;.....|.// Tell| |00004080| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 20 74 6f 20 | applica|tion to | |00004090| 67 69 76 65 20 75 73 20 | 0d 09 09 09 09 09 09 09 |give us |........| |000040a0| 09 09 09 09 09 09 09 2f | 2f 20 61 6e 20 53 48 49 |......./|/ an SHI| |000040b0| 64 6c 65 20 63 61 6c 6c | 2e 0d 09 67 73 53 48 49 |dle call|...gsSHI| |000040c0| 6e 56 61 72 73 2e 72 65 | 63 6f 72 64 43 6f 6d 70 |nVars.re|cordComp| |000040d0| 6c 65 74 65 20 3d 20 74 | 72 75 65 3b 09 09 2f 2f |lete = t|rue;..//| |000040e0| 20 4d 61 6b 65 20 61 20 | 6e 6f 74 65 20 74 6f 20 | Make a |note to | |000040f0| 6f 75 72 73 65 6c 76 65 | 73 2e 0d 09 0d 09 53 65 |ourselve|s.....Se| |00004100| 74 41 35 28 6f 74 68 65 | 72 41 35 29 3b 09 09 09 |tA5(othe|rA5);...| |00004110| 09 09 09 09 09 2f 2f 20 | 52 65 73 74 6f 72 65 20 |.....// |Restore | |00004120| 6f 6c 64 20 41 35 2e 0d | 7d 0d 57 68 65 6e 20 72 |old A5..|}.When r| |00004130| 65 63 6f 72 64 69 6e 67 | 20 68 61 73 20 63 6f 6d |ecording| has com| |00004140| 70 6c 65 74 65 64 20 28 | 66 6f 72 20 61 6e 79 20 |pleted (|for any | |00004150| 72 65 61 73 6f 6e d1 77 | 65 20 66 69 6c 6c 65 64 |reason.w|e filled| |00004160| 20 74 68 65 20 65 6e 74 | 69 72 65 20 62 75 66 66 | the ent|ire buff| |00004170| 65 72 2c 20 61 6e 20 65 | 72 72 6f 72 20 6f 63 63 |er, an e|rror occ| |00004180| 75 72 72 65 64 2c 20 6f | 72 20 74 68 65 20 75 73 |urred, o|r the us| |00004190| 65 72 20 6d 61 6e 75 61 | 6c 6c 79 20 73 74 6f 70 |er manua|lly stop| |000041a0| 70 65 64 20 72 65 63 6f | 72 64 69 6e 67 29 2c 20 |ped reco|rding), | |000041b0| 74 68 65 20 53 6f 75 6e | 64 20 4d 61 6e 61 67 65 |the Soun|d Manage| |000041c0| 72 20 63 61 6c 6c 73 20 | 74 68 65 20 72 65 63 6f |r calls |the reco| |000041d0| 72 64 20 63 61 6c 6c 62 | 61 63 6b 20 72 6f 75 74 |rd callb|ack rout| |000041e0| 69 6e 65 2e 20 4c 69 6b | 65 20 74 68 65 20 70 6c |ine. Lik|e the pl| |000041f0| 61 79 62 61 63 6b 20 63 | 61 6c 6c 62 61 63 6b 20 |ayback c|allback | |00004200| 72 6f 75 74 69 6e 65 2c | 20 69 74 20 66 69 72 73 |routine,| it firs| |00004210| 74 20 73 65 74 73 20 75 | 70 20 74 68 65 20 41 35 |t sets u|p the A5| |00004220| 20 77 6f 72 6c 64 2e 20 | 54 68 65 6e 20 69 74 20 | world. |Then it | |00004230| 73 65 74 73 20 74 68 65 | 20 61 70 70 6c 69 63 61 |sets the| applica| |00004240| 74 69 6f 6e d5 73 20 61 | 74 74 65 6e 74 69 6f 6e |tion.s a|ttention| |00004250| 20 66 6c 61 67 20 61 6e | 64 20 74 68 65 20 72 65 | flag an|d the re| |00004260| 63 6f 72 64 43 6f 6d 70 | 6c 65 74 65 20 66 6c 61 |cordComp|lete fla| |00004270| 67 20 69 6e 73 69 64 65 | 20 74 68 65 20 67 6c 6f |g inside| the glo| |00004280| 62 61 6c 20 53 48 49 6e | 70 75 74 56 61 72 73 20 |bal SHIn|putVars | |00004290| 73 74 72 75 63 74 75 72 | 65 2e 20 4c 61 74 65 72 |structur|e. Later| |000042a0| 2c 20 74 68 65 20 61 70 | 70 6c 69 63 61 74 69 6f |, the ap|plicatio| |000042b0| 6e 20 77 69 6c 6c 20 6e | 6f 74 69 63 65 20 69 74 |n will n|otice it| |000042c0| 73 20 61 74 74 65 6e 74 | 69 6f 6e 20 66 6c 61 67 |s attent|ion flag| |000042d0| 20 69 73 20 73 65 74 20 | 61 6e 64 20 63 61 6c 6c | is set |and call| |000042e0| 20 53 48 49 64 6c 65 2e | 20 53 48 49 64 6c 65 20 | SHIdle.| SHIdle | |000042f0| 63 68 65 63 6b 73 20 74 | 68 65 20 72 65 63 6f 72 |checks t|he recor| |00004300| 64 43 6f 6d 70 6c 65 74 | 65 20 66 6c 61 67 20 61 |dComplet|e flag a| |00004310| 6e 64 20 6e 6f 74 69 63 | 65 73 20 74 68 61 74 20 |nd notic|es that | |00004320| 72 65 63 6f 72 64 69 6e | 67 20 69 73 20 63 6f 6d |recordin|g is com| |00004330| 70 6c 65 74 65 2c 20 63 | 6c 6f 73 65 73 20 74 68 |plete, c|loses th| |00004340| 65 20 73 6f 75 6e 64 20 | 69 6e 70 75 74 20 64 65 |e sound |input de| |00004350| 76 69 63 65 2c 20 61 6e | 64 20 70 72 65 70 61 72 |vice, an|d prepar| |00004360| 65 73 20 66 6f 72 20 74 | 68 65 20 61 70 70 6c 69 |es for t|he appli| |00004370| 63 61 74 69 6f 6e 20 74 | 6f 20 63 61 6c 6c 20 53 |cation t|o call S| |00004380| 48 47 65 74 52 65 63 6f | 72 64 65 64 53 6f 75 6e |HGetReco|rdedSoun| |00004390| 64 20 74 6f 20 72 65 74 | 72 69 65 76 65 20 74 68 |d to ret|rieve th| |000043a0| 65 20 72 65 63 6f 72 64 | 65 64 20 73 6f 75 6e 64 |e record|ed sound| |000043b0| 2e 20 54 68 69 73 20 69 | 73 20 68 6f 77 20 48 65 |. This i|s how He| |000043c0| 6c 70 65 72 20 63 6c 65 | 61 6e 73 20 75 70 20 61 |lper cle|ans up a| |000043d0| 66 74 65 72 20 61 73 79 | 6e 63 68 72 6f 6e 6f 75 |fter asy|nchronou| |000043e0| 73 20 73 6f 75 6e 64 20 | 72 65 63 6f 72 64 69 6e |s sound |recordin| |000043f0| 67 2e 0d 41 6e 6f 74 68 | 65 72 20 68 65 61 76 69 |g..Anoth|er heavi| |00004400| 6c 79 20 75 73 65 64 20 | 73 74 61 74 69 63 20 75 |ly used |static u| |00004410| 74 69 6c 69 74 79 20 72 | 6f 75 74 69 6e 65 20 69 |tility r|outine i| |00004420| 73 20 53 48 4f 75 74 52 | 65 63 46 72 6f 6d 52 65 |s SHOutR|ecFromRe| |00004430| 66 4e 75 6d 2e 20 49 74 | 20 6d 61 70 73 20 61 20 |fNum. It| maps a | |00004440| 73 6f 75 6e 64 20 72 65 | 66 65 72 65 6e 63 65 20 |sound re|ference | |00004450| 6e 75 6d 62 65 72 20 69 | 6e 74 6f 20 61 20 70 6f |number i|nto a po| |00004460| 69 6e 74 65 72 20 74 6f | 20 74 68 65 20 61 70 70 |inter to| the app| |00004470| 72 6f 70 72 69 61 74 65 | 20 53 48 4f 75 74 52 65 |ropriate| SHOutRe| |00004480| 63 2e 0d 53 48 4f 75 74 | 50 74 72 20 53 48 4f 75 |c..SHOut|Ptr SHOu| |00004490| 74 52 65 63 46 72 6f 6d | 52 65 66 4e 75 6d 28 6c |tRecFrom|RefNum(l| |000044a0| 6f 6e 67 20 72 65 66 4e | 75 6d 29 0d 7b 0d 09 73 |ong refN|um).{..s| |000044b0| 68 6f 72 74 09 69 3b 0d | 09 0d 09 2f 2f 20 53 65 |hort.i;.|...// Se| |000044c0| 61 72 63 68 20 66 6f 72 | 20 74 68 65 20 73 70 65 |arch for| the spe| |000044d0| 63 69 66 69 65 64 20 72 | 65 66 4e 75 6d 2e 0d 09 |cified r|efNum...| |000044e0| 66 6f 72 20 28 69 20 3d | 20 30 3b 20 69 20 3c 20 |for (i =| 0; i < | |000044f0| 67 73 53 48 4f 75 74 56 | 61 72 73 2e 6e 75 6d 4f |gsSHOutV|ars.numO| |00004500| 75 74 52 65 63 73 3b 20 | 69 2b 2b 29 0d 09 09 69 |utRecs; |i++)...i| |00004510| 66 20 28 67 73 53 48 4f | 75 74 56 61 72 73 2e 6f |f (gsSHO|utVars.o| |00004520| 75 74 41 72 72 61 79 5b | 69 5d 2e 69 6e 55 73 65 |utArray[|i].inUse| |00004530| 20 26 26 0d 09 09 09 09 | 67 73 53 48 4f 75 74 56 | &&.....|gsSHOutV| |00004540| 61 72 73 2e 6f 75 74 41 | 72 72 61 79 5b 69 5d 2e |ars.outA|rray[i].| |00004550| 72 65 66 4e 75 6d 20 3d | 3d 20 72 65 66 4e 75 6d |refNum =|= refNum| |00004560| 29 0d 09 09 09 62 72 65 | 61 6b 3b 0d 09 0d 09 2f |)....bre|ak;..../| |00004570| 2f 20 49 66 20 77 65 20 | 66 6f 75 6e 64 20 69 74 |/ If we |found it| |00004580| 2c 20 72 65 74 75 72 6e | 20 61 20 70 6f 69 6e 74 |, return| a point| |00004590| 65 72 20 74 6f 20 74 68 | 61 74 20 72 65 63 6f 72 |er to th|at recor| |000045a0| 64 2c 20 6f 74 68 65 72 | 77 69 73 65 20 6e 69 6c |d, other|wise nil| |000045b0| 2e 0d 09 69 66 20 28 69 | 20 3d 3d 20 67 73 53 48 |...if (i| == gsSH| |000045c0| 4f 75 74 56 61 72 73 2e | 6e 75 6d 4f 75 74 52 65 |OutVars.|numOutRe| |000045d0| 63 73 29 0d 09 09 72 65 | 74 75 72 6e 28 6e 69 6c |cs)...re|turn(nil| |000045e0| 29 3b 0d 09 65 6c 73 65 | 20 72 65 74 75 72 6e 28 |);..else| return(| |000045f0| 26 67 73 53 48 4f 75 74 | 56 61 72 73 2e 6f 75 74 |&gsSHOut|Vars.out| |00004600| 41 72 72 61 79 5b 69 5d | 29 3b 0d 7d 0d 53 48 4f |Array[i]|);.}.SHO| |00004610| 75 74 52 65 63 46 72 6f | 6d 52 65 66 4e 75 6d 20 |utRecFro|mRefNum | |00004620| 73 69 6d 70 6c 79 20 64 | 6f 65 73 20 61 20 6c 69 |simply d|oes a li| |00004630| 6e 65 61 72 20 73 65 61 | 72 63 68 20 74 68 72 6f |near sea|rch thro| |00004640| 75 67 68 20 74 68 65 20 | 6f 75 74 70 75 74 20 72 |ugh the |output r| |00004650| 65 63 6f 72 64 73 2c 20 | 6c 6f 6f 6b 69 6e 67 20 |ecords, |looking | |00004660| 66 6f 72 20 61 20 72 65 | 63 6f 72 64 20 74 68 61 |for a re|cord tha| |00004670| 74 20 69 73 20 69 6e 20 | 75 73 65 20 61 6e 64 20 |t is in |use and | |00004680| 68 61 73 20 61 20 6d 61 | 74 63 68 69 6e 67 20 72 |has a ma|tching r| |00004690| 65 66 65 72 65 6e 63 65 | 20 6e 75 6d 62 65 72 2e |eference| number.| |000046a0| 20 49 66 20 6e 6f 6e 65 | 20 69 73 20 66 6f 75 6e | If none| is foun| |000046b0| 64 2c 20 6e 69 6c 20 69 | 73 20 72 65 74 75 72 6e |d, nil i|s return| |000046c0| 65 64 2e 0d 57 65 d5 6c | 6c 20 69 6e 76 65 73 74 |ed..We.l|l invest| |000046d0| 69 67 61 74 65 20 61 20 | 66 65 77 20 6d 6f 72 65 |igate a |few more| |000046e0| 20 75 74 69 6c 69 74 79 | 20 72 6f 75 74 69 6e 65 | utility| routine| |000046f0| 73 20 61 73 20 77 65 20 | 64 65 6c 76 65 20 69 6e |s as we |delve in| |00004700| 74 6f 20 74 68 65 20 64 | 65 74 61 69 6c 73 20 6f |to the d|etails o| |00004710| 66 20 74 68 65 20 70 75 | 62 6c 69 63 20 72 6f 75 |f the pu|blic rou| |00004720| 74 69 6e 65 73 20 69 6e | 20 74 68 65 20 73 65 63 |tines in| the sec| |00004730| 74 69 6f 6e 73 20 74 68 | 61 74 20 66 6f 6c 6c 6f |tions th|at follo| |00004740| 77 2e 0d 48 45 4c 50 45 | 52 27 53 20 49 4e 49 54 |w..HELPE|R'S INIT| |00004750| 49 41 4c 49 5a 41 54 49 | 4f 4e 2c 20 54 45 52 4d |IALIZATI|ON, TERM| |00004760| 49 4e 41 54 49 4f 4e 2c | 20 41 4e 44 20 49 44 4c |INATION,| AND IDL| |00004770| 45 20 52 4f 55 54 49 4e | 45 53 0d 4c 65 74 d5 73 |E ROUTIN|ES.Let.s| |00004780| 20 74 61 6b 65 20 61 20 | 63 6c 6f 73 65 72 20 6c | take a |closer l| |00004790| 6f 6f 6b 20 61 74 20 74 | 68 65 20 53 48 49 6e 69 |ook at t|he SHIni| |000047a0| 74 53 6f 75 6e 64 48 65 | 6c 70 65 72 2c 20 53 48 |tSoundHe|lper, SH| |000047b0| 4b 69 6c 6c 53 6f 75 6e | 64 48 65 6c 70 65 72 2c |KillSoun|dHelper,| |000047c0| 20 61 6e 64 20 53 48 49 | 64 6c 65 20 72 6f 75 74 | and SHI|dle rout| |000047d0| 69 6e 65 73 2e 0d 53 48 | 49 4e 49 54 53 4f 55 4e |ines..SH|INITSOUN| |000047e0| 44 48 45 4c 50 45 52 0d | 70 61 73 63 61 6c 20 4f |DHELPER.|pascal O| |000047f0| 53 45 72 72 20 53 48 49 | 6e 69 74 53 6f 75 6e 64 |SErr SHI|nitSound| |00004800| 48 65 6c 70 65 72 28 42 | 6f 6f 6c 65 61 6e 20 2a |Helper(B|oolean *| |00004810| 61 74 74 6e 46 6c 61 67 | 2c 20 73 68 6f 72 74 20 |attnFlag|, short | |00004820| 6e 75 6d 43 68 61 6e 6e | 65 6c 73 29 0d 7b 0d 09 |numChann|els).{..| |00004830| 4f 53 45 72 72 09 65 72 | 72 3b 0d 09 0d 09 2f 2f |OSErr.er|r;....//| |00004840| 20 55 73 65 20 64 65 66 | 61 75 6c 74 20 6e 75 6d | Use def|ault num| |00004850| 62 65 72 20 6f 66 20 63 | 68 61 6e 6e 65 6c 73 20 |ber of c|hannels | |00004860| 69 66 20 7a 65 72 6f 20 | 77 61 73 20 73 70 65 63 |if zero |was spec| |00004870| 69 66 69 65 64 2e 0d 09 | 69 66 20 28 6e 75 6d 43 |ified...|if (numC| |00004880| 68 61 6e 6e 65 6c 73 20 | 3d 3d 20 30 29 0d 09 09 |hannels |== 0)...| |00004890| 6e 75 6d 43 68 61 6e 6e | 65 6c 73 20 3d 20 6b 53 |numChann|els = kS| |000048a0| 48 44 65 66 43 68 61 6e | 6e 65 6c 73 3b 0d 09 0d |HDefChan|nels;...| |000048b0| 09 2f 2f 20 52 65 6d 65 | 6d 62 65 72 20 74 68 65 |.// Reme|mber the| |000048c0| 20 61 64 64 72 65 73 73 | 20 6f 66 20 74 68 65 20 | address| of the | |000048d0| 61 70 70 6c 69 63 61 74 | 69 6f 6e 27 73 20 61 74 |applicat|ion's at| |000048e0| 74 65 6e 74 69 6f 6e 20 | 66 6c 61 67 2e 0d 09 67 |tention |flag...g| |000048f0| 73 53 48 4e 65 65 64 73 | 54 69 6d 65 20 3d 20 61 |sSHNeeds|Time = a| |00004900| 74 74 6e 46 6c 61 67 3b | 0d 09 0d 09 2f 2f 20 41 |ttnFlag;|....// A| |00004910| 6c 6c 6f 63 61 74 65 20 | 74 68 65 20 63 68 61 6e |llocate |the chan| |00004920| 6e 65 6c 73 2e 0d 09 67 | 73 53 48 4f 75 74 56 61 |nels...g|sSHOutVa| |00004930| 72 73 2e 6e 75 6d 4f 75 | 74 52 65 63 73 20 3d 20 |rs.numOu|tRecs = | |00004940| 6e 75 6d 43 68 61 6e 6e | 65 6c 73 3b 0d 09 67 73 |numChann|els;..gs| |00004950| 53 48 4f 75 74 56 61 72 | 73 2e 6f 75 74 41 72 72 |SHOutVar|s.outArr| |00004960| 61 79 20 3d 20 28 53 48 | 4f 75 74 50 74 72 29 4e |ay = (SH|OutPtr)N| |00004970| 65 77 50 74 72 43 6c 65 | 61 72 28 6e 75 6d 43 68 |ewPtrCle|ar(numCh| |00004980| 61 6e 6e 65 6c 73 20 2a | 0d 09 09 73 69 7a 65 6f |annels *|...sizeo| |00004990| 66 28 53 48 4f 75 74 52 | 65 63 29 29 3b 0d 09 2f |f(SHOutR|ec));../| |000049a0| 2f 20 49 66 20 73 75 63 | 63 65 73 73 66 75 6c 2c |/ If suc|cessful,| |000049b0| 20 66 6c 61 67 20 74 68 | 61 74 20 77 65 27 72 65 | flag th|at we're| |000049c0| 20 69 6e 69 74 69 61 6c | 69 7a 65 64 20 61 6e 64 | initial|ized and| |000049d0| 20 65 78 69 74 2e 0d 09 | 69 66 20 28 67 73 53 48 | exit...|if (gsSH| |000049e0| 4f 75 74 56 61 72 73 2e | 6f 75 74 41 72 72 61 79 |OutVars.|outArray| |000049f0| 20 21 3d 20 6e 69 6c 29 | 20 7b 0d 09 09 67 73 53 | != nil)| {...gsS| |00004a00| 48 49 6e 69 74 65 64 20 | 3d 20 74 72 75 65 3b 0d |HInited |= true;.| |00004a10| 09 09 72 65 74 75 72 6e | 28 6e 6f 45 72 72 29 3b |..return|(noErr);| |00004a20| 0d 09 7d 20 65 6c 73 65 | 20 7b 0d 09 09 2f 2f 20 |..} else| {...// | |00004a30| 52 65 74 75 72 6e 20 73 | 6f 6d 65 20 6b 69 6e 64 |Return s|ome kind| |00004a40| 20 6f 66 20 65 72 72 6f | 72 20 28 4d 65 6d 45 72 | of erro|r (MemEr| |00004a50| 72 6f 72 20 69 66 20 74 | 68 65 72 65 20 69 73 20 |ror if t|here is | |00004a60| 6f 6e 65 2c 20 6f 74 68 | 65 72 77 69 73 65 0d 09 |one, oth|erwise..| |00004a70| 09 2f 2f 20 6d 61 6b 65 | 20 6f 6e 65 20 75 70 29 |.// make| one up)| |00004a80| 2e 0d 09 09 65 72 72 20 | 3d 20 4d 65 6d 45 72 72 |....err |= MemErr| |00004a90| 6f 72 28 29 3b 0d 09 09 | 69 66 20 28 65 72 72 20 |or();...|if (err | |00004aa0| 3d 3d 20 6e 6f 45 72 72 | 29 0d 09 09 09 65 72 72 |== noErr|)....err| |00004ab0| 20 3d 20 6d 65 6d 46 75 | 6c 6c 45 72 72 3b 0d 09 | = memFu|llErr;..| |00004ac0| 09 72 65 74 75 72 6e 28 | 65 72 72 29 3b 0d 09 7d |.return(|err);..}| |00004ad0| 0d 7d 0d 53 48 49 6e 69 | 74 53 6f 75 6e 64 48 65 |.}.SHIni|tSoundHe| |00004ae0| 6c 70 65 72 20 69 73 20 | 66 61 69 72 6c 79 20 75 |lper is |fairly u| |00004af0| 6e 63 6f 6d 70 6c 69 63 | 61 74 65 64 2e 20 54 68 |ncomplic|ated. Th| |00004b00| 65 20 61 74 74 6e 46 6c | 61 67 20 70 61 72 61 6d |e attnFl|ag param| |00004b10| 65 74 65 72 20 70 6f 69 | 6e 74 73 20 74 6f 20 74 |eter poi|nts to t| |00004b20| 68 65 20 61 70 70 6c 69 | 63 61 74 69 6f 6e d5 73 |he appli|cation.s| |00004b30| 20 61 74 74 65 6e 74 69 | 6f 6e 20 66 6c 61 67 2c | attenti|on flag,| |00004b40| 20 77 68 69 63 68 20 69 | 73 20 75 73 65 64 20 74 | which i|s used t| |00004b50| 6f 20 74 65 6c 6c 20 74 | 68 65 20 61 70 70 6c 69 |o tell t|he appli| |00004b60| 63 61 74 69 6f 6e 20 74 | 68 61 74 20 61 20 63 61 |cation t|hat a ca| |00004b70| 6c 6c 20 74 6f 20 53 48 | 49 64 6c 65 20 69 73 20 |ll to SH|Idle is | |00004b80| 6e 65 65 64 65 64 2e 20 | 54 68 65 20 6e 75 6d 43 |needed. |The numC| |00004b90| 68 61 6e 6e 65 6c 73 20 | 70 61 72 61 6d 65 74 65 |hannels |paramete| |00004ba0| 72 20 74 65 6c 6c 73 20 | 48 65 6c 70 65 72 20 68 |r tells |Helper h| |00004bb0| 6f 77 20 6d 61 6e 79 20 | 63 68 61 6e 6e 65 6c 73 |ow many |channels| |00004bc0| 20 74 6f 20 61 6c 6c 6f | 63 61 74 65 2e 20 54 68 | to allo|cate. Th| |00004bd0| 65 20 6e 75 6d 62 65 72 | 20 6f 66 20 73 69 6d 75 |e number| of simu| |00004be0| 6c 74 61 6e 65 6f 75 73 | 20 73 6f 75 6e 64 73 20 |ltaneous| sounds | |00004bf0| 74 68 61 74 20 63 61 6e | 20 62 65 20 70 6c 61 79 |that can| be play| |00004c00| 65 64 20 62 61 63 6b 20 | 62 79 20 48 65 6c 70 65 |ed back |by Helpe| |00004c10| 72 20 69 73 20 6c 69 6d | 69 74 65 64 20 62 79 20 |r is lim|ited by | |00004c20| 74 68 65 20 6e 75 6d 62 | 65 72 20 6f 66 20 63 68 |the numb|er of ch| |00004c30| 61 6e 6e 65 6c 73 20 61 | 6c 6c 6f 63 61 74 65 64 |annels a|llocated| |00004c40| 20 28 76 69 61 20 6e 75 | 6d 43 68 61 6e 6e 65 6c | (via nu|mChannel| |00004c50| 73 29 20 61 6e 64 20 74 | 68 65 20 6e 75 6d 62 65 |s) and t|he numbe| |00004c60| 72 20 6f 66 20 73 69 6d | 75 6c 74 61 6e 65 6f 75 |r of sim|ultaneou| |00004c70| 73 20 73 6f 75 6e 64 20 | 63 68 61 6e 6e 65 6c 73 |s sound |channels| |00004c80| 20 74 68 65 20 53 6f 75 | 6e 64 20 4d 61 6e 61 67 | the Sou|nd Manag| |00004c90| 65 72 20 61 6c 6c 6f 77 | 73 2e 20 53 6f 20 75 73 |er allow|s. So us| |00004ca0| 65 20 61 20 6e 75 6d 43 | 68 61 6e 6e 65 6c 73 20 |e a numC|hannels | |00004cb0| 74 68 61 74 d5 73 20 61 | 70 70 72 6f 70 72 69 61 |that.s a|ppropria| |00004cc0| 74 65 20 74 6f 20 79 6f | 75 72 20 6e 65 65 64 73 |te to yo|ur needs| |00004cd0| 2e 20 49 66 20 79 6f 75 | 20 73 70 65 63 69 66 79 |. If you| specify| |00004ce0| 20 7a 65 72 6f 2c 20 61 | 20 72 65 61 73 6f 6e 61 | zero, a| reasona| |00004cf0| 62 6c 65 20 64 65 66 61 | 75 6c 74 20 28 66 6f 75 |ble defa|ult (fou| |00004d00| 72 29 20 69 73 20 75 73 | 65 64 2e 20 53 48 49 6e |r) is us|ed. SHIn| |00004d10| 69 74 53 6f 75 6e 64 48 | 65 6c 70 65 72 20 61 6c |itSoundH|elper al| |00004d20| 6c 6f 63 61 74 65 73 20 | 74 68 65 20 6f 75 74 70 |locates |the outp| |00004d30| 75 74 20 72 65 63 6f 72 | 64 73 20 61 6e 64 20 73 |ut recor|ds and s| |00004d40| 74 6f 72 65 73 20 61 20 | 70 6f 69 6e 74 65 72 20 |tores a |pointer | |00004d50| 74 6f 20 74 68 65 20 61 | 72 72 61 79 20 69 6e 20 |to the a|rray in | |00004d60| 67 73 53 48 4f 75 74 56 | 61 72 73 2e 20 49 66 20 |gsSHOutV|ars. If | |00004d70| 74 68 65 20 6d 65 6d 6f | 72 79 20 61 6c 6c 6f 63 |the memo|ry alloc| |00004d80| 61 74 69 6f 6e 20 69 73 | 20 73 75 63 63 65 73 73 |ation is| success| |00004d90| 66 75 6c 2c 20 67 73 53 | 48 49 6e 69 74 65 64 20 |ful, gsS|HInited | |00004da0| 69 73 20 73 65 74 20 74 | 6f 20 74 72 75 65 2e 0d |is set t|o true..| |00004db0| 53 48 4b 49 4c 4c 53 4f | 55 4e 44 48 45 4c 50 45 |SHKILLSO|UNDHELPE| |00004dc0| 52 0d 70 61 73 63 61 6c | 20 76 6f 69 64 20 53 48 |R.pascal| void SH| |00004dd0| 4b 69 6c 6c 53 6f 75 6e | 64 48 65 6c 70 65 72 28 |KillSoun|dHelper(| |00004de0| 76 6f 69 64 29 0d 7b 0d | 09 73 68 6f 72 74 09 69 |void).{.|.short.i| |00004df0| 3b 0d 09 6c 6f 6e 67 09 | 09 74 69 6d 65 6f 75 74 |;..long.|.timeout| |00004e00| 3b 0d 09 42 6f 6f 6c 65 | 61 6e 09 6f 75 74 70 75 |;..Boole|an.outpu| |00004e10| 74 43 6c 65 61 6e 2c 20 | 69 6e 70 75 74 43 6c 65 |tClean, |inputCle| |00004e20| 61 6e 3b 0d 09 0d 09 69 | 66 20 28 21 67 73 53 48 |an;....i|f (!gsSH| |00004e30| 49 6e 69 74 65 64 29 0d | 09 09 72 65 74 75 72 6e |Inited).|..return| |00004e40| 3b 0d 09 53 48 50 6c 61 | 79 53 74 6f 70 41 6c 6c |;..SHPla|yStopAll| |00004e50| 28 29 3b 09 09 2f 2f 20 | 4b 69 6c 6c 20 61 6c 6c |();..// |Kill all| |00004e60| 20 70 6c 61 79 62 61 63 | 6b 2e 0d 09 53 48 52 65 | playbac|k...SHRe| |00004e70| 63 6f 72 64 53 74 6f 70 | 28 29 3b 09 09 2f 2f 20 |cordStop|();..// | |00004e80| 4b 69 6c 6c 20 72 65 63 | 6f 72 64 69 6e 67 2e 0d |Kill rec|ording..| |00004e90| 09 0d 09 2f 2f 20 4e 6f | 77 20 73 79 6e 63 2d 77 |...// No|w sync-w| |00004ea0| 61 69 74 20 66 6f 72 20 | 65 76 65 72 79 74 68 69 |ait for |everythi| |00004eb0| 6e 67 20 74 6f 20 63 6c | 65 61 6e 20 69 74 73 65 |ng to cl|ean itse| |00004ec0| 6c 66 20 75 70 2e 0d 09 | 74 69 6d 65 6f 75 74 20 |lf up...|timeout | |00004ed0| 3d 20 54 69 63 6b 43 6f | 75 6e 74 28 29 20 2b 20 |= TickCo|unt() + | |00004ee0| 6b 53 48 53 79 6e 63 57 | 61 69 74 54 69 6d 65 6f |kSHSyncW|aitTimeo| |00004ef0| 75 74 3b 0d 09 64 6f 20 | 7b 0d 09 09 69 66 20 28 |ut;..do |{...if (| |00004f00| 2a 67 73 53 48 4e 65 65 | 64 73 54 69 6d 65 29 0d |*gsSHNee|dsTime).| |00004f10| 09 09 09 53 48 49 64 6c | 65 28 29 3b 09 09 2f 2f |...SHIdl|e();..//| |00004f20| 20 43 6c 65 61 6e 20 75 | 70 20 77 68 65 6e 20 72 | Clean u|p when r| |00004f30| 65 71 75 69 72 65 64 2e | 0d 09 09 2f 2f 20 43 68 |equired.|...// Ch| |00004f40| 65 63 6b 20 77 68 65 74 | 68 65 72 20 61 6c 6c 20 |eck whet|her all | |00004f50| 6f 75 72 20 6f 75 74 70 | 75 74 20 63 68 61 6e 6e |our outp|ut chann| |00004f60| 65 6c 73 20 61 72 65 20 | 63 6c 65 61 6e 65 64 20 |els are |cleaned | |00004f70| 75 70 2e 0d 09 09 6f 75 | 74 70 75 74 43 6c 65 61 |up....ou|tputClea| |00004f80| 6e 20 3d 20 74 72 75 65 | 3b 0d 09 09 66 6f 72 20 |n = true|;...for | |00004f90| 28 69 20 3d 20 30 3b 20 | 69 20 3c 20 67 73 53 48 |(i = 0; |i < gsSH| |00004fa0| 4f 75 74 56 61 72 73 2e | 6e 75 6d 4f 75 74 52 65 |OutVars.|numOutRe| |00004fb0| 63 73 20 26 26 20 6f 75 | 74 70 75 74 43 6c 65 61 |cs && ou|tputClea| |00004fc0| 6e 3b 20 69 2b 2b 29 0d | 09 09 09 69 66 20 28 67 |n; i++).|...if (g| |00004fd0| 73 53 48 4f 75 74 56 61 | 72 73 2e 6f 75 74 41 72 |sSHOutVa|rs.outAr| |00004fe0| 72 61 79 5b 69 5d 2e 69 | 6e 55 73 65 29 0d 09 09 |ray[i].i|nUse)...| |00004ff0| 09 09 6f 75 74 70 75 74 | 43 6c 65 61 6e 20 3d 20 |..output|Clean = | |00005000| 66 61 6c 73 65 3b 0d 09 | 09 0d 09 09 2f 2f 20 43 |false;..|....// C| |00005010| 68 65 63 6b 20 77 68 65 | 74 68 65 72 20 6f 75 72 |heck whe|ther our| |00005020| 20 72 65 63 6f 72 64 69 | 6e 67 20 69 73 20 63 6c | recordi|ng is cl| |00005030| 65 61 6e 65 64 20 75 70 | 2e 0d 09 09 69 6e 70 75 |eaned up|....inpu| |00005040| 74 43 6c 65 61 6e 20 3d | 20 21 67 73 53 48 49 6e |tClean =| !gsSHIn| |00005050| 56 61 72 73 2e 72 65 63 | 6f 72 64 69 6e 67 3b 0d |Vars.rec|ording;.| |00005060| 09 09 0d 09 09 69 66 20 | 28 69 6e 70 75 74 43 6c |.....if |(inputCl| |00005070| 65 61 6e 20 26 26 20 6f | 75 74 70 75 74 43 6c 65 |ean && o|utputCle| |00005080| 61 6e 29 0d 09 09 09 62 | 72 65 61 6b 3b 0d 09 7d |an)....b|reak;..}| |00005090| 20 77 68 69 6c 65 20 28 | 54 69 63 6b 43 6f 75 6e | while (|TickCoun| |000050a0| 74 28 29 20 3c 20 74 69 | 6d 65 6f 75 74 29 3b 0d |t() < ti|meout);.| |000050b0| 09 0d 09 2f 2f 20 4c 6f | 73 65 20 6f 75 72 20 70 |...// Lo|se our p| |000050c0| 72 65 61 6c 6c 6f 63 61 | 74 65 64 20 73 6f 75 6e |realloca|ted soun| |000050d0| 64 20 63 68 61 6e 6e 65 | 6c 73 2e 0d 09 44 69 73 |d channe|ls...Dis| |000050e0| 70 6f 73 65 50 74 72 28 | 28 50 74 72 29 67 73 53 |posePtr(|(Ptr)gsS| |000050f0| 48 4f 75 74 56 61 72 73 | 2e 6f 75 74 41 72 72 61 |HOutVars|.outArra| |00005100| 79 29 3b 0d 7d 0d 0d 53 | 48 4b 69 6c 6c 53 6f 75 |y);.}..S|HKillSou| |00005110| 6e 64 48 65 6c 70 65 72 | 20 66 69 72 73 74 20 73 |ndHelper| first s| |00005120| 74 6f 70 73 20 61 6e 79 | 20 61 73 79 6e 63 68 72 |tops any| asynchr| |00005130| 6f 6e 6f 75 73 20 73 6f | 75 6e 64 20 69 6e 70 75 |onous so|und inpu| |00005140| 74 20 6f 72 20 6f 75 74 | 70 75 74 20 69 6e 20 70 |t or out|put in p| |00005150| 72 6f 67 72 65 73 73 2e | 20 49 74 20 77 61 69 74 |rogress.| It wait| |00005160| 73 20 66 6f 72 20 61 6c | 6c 20 74 68 65 20 6f 75 |s for al|l the ou| |00005170| 74 70 75 74 20 63 68 61 | 6e 6e 65 6c 73 20 74 6f |tput cha|nnels to| |00005180| 20 62 65 20 66 72 65 65 | 20 61 6e 64 20 66 6f 72 | be free| and for| |00005190| 20 72 65 63 6f 72 64 69 | 6e 67 20 74 6f 20 73 74 | recordi|ng to st| |000051a0| 6f 70 20 62 65 66 6f 72 | 65 20 63 6f 6e 74 69 6e |op befor|e contin| |000051b0| 75 69 6e 67 2e 20 46 69 | 6e 61 6c 6c 79 2c 20 69 |uing. Fi|nally, i| |000051c0| 74 20 64 69 73 70 6f 73 | 65 73 20 6f 66 20 74 68 |t dispos|es of th| |000051d0| 65 20 6f 75 74 70 75 74 | 20 72 65 63 6f 72 64 20 |e output| record | |000051e0| 61 72 72 61 79 2e 0d 53 | 48 49 44 4c 45 0d 70 61 |array..S|HIDLE.pa| |000051f0| 73 63 61 6c 20 76 6f 69 | 64 20 53 48 49 64 6c 65 |scal voi|d SHIdle| |00005200| 28 76 6f 69 64 29 0d 7b | 0d 20 20 73 68 6f 72 74 |(void).{|. short| |00005210| 09 69 3b 0d 20 20 4f 53 | 45 72 72 09 65 72 72 3b |.i;. OS|Err.err;| |00005220| 0d 20 20 6c 6f 6e 67 09 | 72 65 61 6c 53 69 7a 65 |. long.|realSize| |00005230| 3b 0d 09 0d 09 2f 2f 20 | 49 6d 6d 65 64 69 61 74 |;....// |Immediat| |00005240| 65 6c 79 20 74 75 72 6e | 20 6f 66 66 20 74 68 65 |ely turn| off the| |00005250| 20 61 70 70 6c 69 63 61 | 74 69 6f 6e 27 73 20 61 | applica|tion's a| |00005260| 74 74 65 6e 74 69 6f 6e | 20 66 6c 61 67 2e 0d 09 |ttention| flag...| |00005270| 2a 67 73 53 48 4e 65 65 | 64 73 54 69 6d 65 20 3d |*gsSHNee|dsTime =| |00005280| 20 66 61 6c 73 65 3b 0d | 09 2f 2f 20 44 6f 20 70 | false;.|.// Do p| |00005290| 6c 61 79 62 61 63 6b 20 | 63 6c 65 61 6e 75 70 2e |layback |cleanup.| |000052a0| 0d 09 66 6f 72 20 28 69 | 20 3d 20 30 3b 20 69 20 |..for (i| = 0; i | |000052b0| 3c 20 67 73 53 48 4f 75 | 74 56 61 72 73 2e 6e 75 |< gsSHOu|tVars.nu| |000052c0| 6d 4f 75 74 52 65 63 73 | 3b 20 69 2b 2b 29 0d 09 |mOutRecs|; i++)..| |000052d0| 09 69 66 20 28 67 73 53 | 48 4f 75 74 56 61 72 73 |.if (gsS|HOutVars| |000052e0| 2e 6f 75 74 41 72 72 61 | 79 5b 69 5d 2e 69 6e 55 |.outArra|y[i].inU| |000052f0| 73 65 20 26 26 0d 09 09 | 09 09 67 73 53 48 4f 75 |se &&...|..gsSHOu| |00005300| 74 56 61 72 73 2e 6f 75 | 74 41 72 72 61 79 5b 69 |tVars.ou|tArray[i| |00005310| 5d 2e 63 68 61 6e 6e 65 | 6c 2e 75 73 65 72 49 6e |].channe|l.userIn| |00005320| 66 6f 20 3d 3d 20 6b 53 | 48 43 6f 6d 70 6c 65 74 |fo == kS|HComplet| |00005330| 65 29 0d 09 09 09 2f 2f | 20 57 65 27 76 65 20 66 |e)....//| We've f| |00005340| 6f 75 6e 64 20 61 20 63 | 68 61 6e 6e 65 6c 20 74 |ound a c|hannel t| |00005350| 68 61 74 20 6e 65 65 64 | 73 20 63 6c 6f 73 69 6e |hat need|s closin| |00005360| 67 2e 0d 09 09 09 53 48 | 52 65 6c 65 61 73 65 4f |g.....SH|ReleaseO| |00005370| 75 74 52 65 63 28 26 67 | 73 53 48 4f 75 74 56 61 |utRec(&g|sSHOutVa| |00005380| 72 73 2e 6f 75 74 41 72 | 72 61 79 5b 69 5d 29 3b |rs.outAr|ray[i]);| |00005390| 0d 09 0d 09 2f 2f 20 44 | 6f 20 72 65 63 6f 72 64 |....// D|o record| |000053a0| 69 6e 67 20 63 6c 65 61 | 6e 75 70 2e 0d 09 69 66 |ing clea|nup...if| |000053b0| 20 28 67 73 53 48 49 6e | 56 61 72 73 2e 72 65 63 | (gsSHIn|Vars.rec| |000053c0| 6f 72 64 69 6e 67 20 26 | 26 20 67 73 53 48 49 6e |ording &|& gsSHIn| |000053d0| 56 61 72 73 2e 72 65 63 | 6f 72 64 43 6f 6d 70 6c |Vars.rec|ordCompl| |000053e0| 65 74 65 29 20 7b 0d 09 | 09 48 55 6e 6c 6f 63 6b |ete) {..|.HUnlock| |000053f0| 28 67 73 53 48 49 6e 56 | 61 72 73 2e 69 6e 48 61 |(gsSHInV|ars.inHa| |00005400| 6e 64 6c 65 29 3b 0d 09 | 09 69 66 20 28 67 73 53 |ndle);..|.if (gsS| |00005410| 48 49 6e 56 61 72 73 2e | 69 6e 50 42 2e 65 72 72 |HInVars.|inPB.err| |00005420| 6f 72 20 26 26 20 67 73 | 53 48 49 6e 56 61 72 73 |or && gs|SHInVars| |00005430| 2e 69 6e 50 42 2e 65 72 | 72 6f 72 20 21 3d 20 61 |.inPB.er|ror != a| |00005440| 62 6f 72 74 45 72 72 29 | 20 7b 0d 09 09 09 2f 2f |bortErr)| {....//| |00005450| 20 41 6e 20 65 72 72 6f | 72 20 28 6f 74 68 65 72 | An erro|r (other| |00005460| 20 74 68 61 6e 20 61 20 | 6d 61 6e 75 61 6c 20 73 | than a |manual s| |00005470| 74 6f 70 29 20 6f 63 63 | 75 72 72 65 64 20 64 75 |top) occ|urred du| |00005480| 72 69 6e 67 0d 09 09 09 | 2f 2f 20 72 65 63 6f 72 |ring....|// recor| |00005490| 64 69 6e 67 2e 20 4b 69 | 6c 6c 20 74 68 65 20 68 |ding. Ki|ll the h| |000054a0| 61 6e 64 6c 65 20 61 6e | 64 20 73 61 76 65 20 74 |andle an|d save t| |000054b0| 68 65 20 65 72 72 6f 72 | 20 63 6f 64 65 2e 0d 09 |he error| code...| |000054c0| 09 09 67 73 53 48 49 6e | 56 61 72 73 2e 72 65 63 |..gsSHIn|Vars.rec| |000054d0| 6f 72 64 45 72 72 20 3d | 20 67 73 53 48 49 6e 56 |ordErr =| gsSHInV| |000054e0| 61 72 73 2e 69 6e 50 42 | 2e 65 72 72 6f 72 3b 0d |ars.inPB|.error;.| |000054f0| 09 09 09 44 69 73 70 6f | 73 65 48 61 6e 64 6c 65 |...Dispo|seHandle| |00005500| 28 67 73 53 48 49 6e 56 | 61 72 73 2e 69 6e 48 61 |(gsSHInV|ars.inHa| |00005510| 6e 64 6c 65 29 3b 0d 09 | 09 09 67 73 53 48 49 6e |ndle);..|..gsSHIn| |00005520| 56 61 72 73 2e 69 6e 48 | 61 6e 64 6c 65 20 3d 20 |Vars.inH|andle = | |00005530| 6e 69 6c 3b 0d 09 09 7d | 20 65 6c 73 65 20 7b 0d |nil;...}| else {.| |00005540| 09 09 09 2f 2f 20 52 65 | 63 6f 72 64 69 6e 67 20 |...// Re|cording | |00005550| 63 6f 6d 70 6c 65 74 65 | 64 20 6e 6f 72 6d 61 6c |complete|d normal| |00005560| 6c 79 20 28 77 68 69 63 | 68 20 69 6e 63 6c 75 64 |ly (whic|h includ| |00005570| 65 73 20 61 62 6f 72 74 | 45 72 72 2c 20 74 68 65 |es abort|Err, the| |00005580| 0d 09 09 09 2f 2f 20 22 | 65 72 72 6f 72 22 20 74 |....// "|error" t| |00005590| 68 61 74 20 6f 63 63 75 | 72 73 20 77 68 65 6e 20 |hat occu|rs when | |000055a0| 72 65 63 6f 72 64 69 6e | 67 20 69 73 20 73 74 6f |recordin|g is sto| |000055b0| 70 70 65 64 20 6d 61 6e | 75 61 6c 6c 79 29 2e 0d |pped man|ually)..| |000055c0| 09 09 09 67 73 53 48 49 | 6e 56 61 72 73 2e 72 65 |...gsSHI|nVars.re| |000055d0| 63 6f 72 64 45 72 72 20 | 3d 20 6e 6f 45 72 72 3b |cordErr |= noErr;| |000055e0| 0d 09 09 09 72 65 61 6c | 53 69 7a 65 20 3d 20 67 |....real|Size = g| |000055f0| 73 53 48 49 6e 56 61 72 | 73 2e 69 6e 50 42 2e 63 |sSHInVar|s.inPB.c| |00005600| 6f 75 6e 74 20 2b 20 67 | 73 53 48 49 6e 56 61 72 |ount + g|sSHInVar| |00005610| 73 2e 68 65 61 64 65 72 | 4c 65 6e 67 74 68 3b 0d |s.header|Length;.| |00005620| 09 09 09 65 72 72 20 3d | 20 53 65 74 75 70 53 6e |...err =| SetupSn| |00005630| 64 48 65 61 64 65 72 28 | 67 73 53 48 49 6e 56 61 |dHeader(|gsSHInVa| |00005640| 72 73 2e 69 6e 48 61 6e | 64 6c 65 2c 20 09 09 09 |rs.inHan|dle, ...| |00005650| 0d 09 09 09 09 67 73 53 | 48 49 6e 56 61 72 73 2e |.....gsS|HInVars.| |00005660| 6e 75 6d 43 68 61 6e 6e | 65 6c 73 2c 0d 09 09 09 |numChann|els,....| |00005670| 09 67 73 53 48 49 6e 56 | 61 72 73 2e 73 61 6d 70 |.gsSHInV|ars.samp| |00005680| 6c 65 52 61 74 65 2c 20 | 67 73 53 48 49 6e 56 61 |leRate, |gsSHInVa| |00005690| 72 73 2e 73 61 6d 70 6c | 65 53 69 7a 65 2c 0d 09 |rs.sampl|eSize,..| |000056a0| 09 09 09 67 73 53 48 49 | 6e 56 61 72 73 2e 63 6f |...gsSHI|nVars.co| |000056b0| 6d 70 54 79 70 65 2c 20 | 6b 53 48 42 61 73 65 4e |mpType, |kSHBaseN| |000056c0| 6f 74 65 2c 20 72 65 61 | 6c 53 69 7a 65 2c 20 0d |ote, rea|lSize, .| |000056d0| 09 09 09 09 26 67 73 53 | 48 49 6e 56 61 72 73 2e |....&gsS|HInVars.| |000056e0| 68 65 61 64 65 72 4c 65 | 6e 67 74 68 29 3b 0d 09 |headerLe|ngth);..| |000056f0| 09 09 53 65 74 48 61 6e | 64 6c 65 53 69 7a 65 28 |..SetHan|dleSize(| |00005700| 67 73 53 48 49 6e 56 61 | 72 73 2e 69 6e 48 61 6e |gsSHInVa|rs.inHan| |00005710| 64 6c 65 2c 20 72 65 61 | 6c 53 69 7a 65 29 3b 0d |dle, rea|lSize);.| |00005720| 09 09 7d 0d 09 09 2f 2f | 20 45 72 72 6f 72 20 6f |..}...//| Error o| |00005730| 72 20 6e 6f 74 2c 20 63 | 6c 6f 73 65 20 74 68 65 |r not, c|lose the| |00005740| 20 72 65 63 6f 72 64 69 | 6e 67 20 64 65 76 69 63 | recordi|ng devic| |00005750| 65 20 61 6e 64 20 74 65 | 6c 6c 20 74 68 65 20 61 |e and te|ll the a| |00005760| 70 70 6c 69 63 61 74 69 | 6f 6e 0d 09 09 2f 2f 20 |pplicati|on...// | |00005770| 74 68 61 74 20 72 65 63 | 6f 72 64 69 6e 67 20 69 |that rec|ording i| |00005780| 73 20 63 6f 6d 70 6c 65 | 74 65 20 74 68 72 6f 75 |s comple|te throu| |00005790| 67 68 20 74 68 65 20 72 | 65 63 6f 72 64 69 6e 67 |gh the r|ecording| |000057a0| 2d 63 6f 6d 70 6c 65 74 | 65 64 0d 09 09 2f 2f 20 |-complet|ed...// | |000057b0| 66 6c 61 67 20 74 68 61 | 74 20 74 68 65 20 63 61 |flag tha|t the ca| |000057c0| 6c 6c 65 72 20 6f 72 69 | 67 69 6e 61 6c 6c 79 20 |ller ori|ginally | |000057d0| 70 61 73 73 65 64 20 69 | 6e 74 6f 20 53 48 52 65 |passed i|nto SHRe| |000057e0| 63 6f 72 64 53 74 61 72 | 74 2e 0d 0d 09 09 53 50 |cordStar|t.....SP| |000057f0| 42 43 6c 6f 73 65 44 65 | 76 69 63 65 28 67 73 53 |BCloseDe|vice(gsS| |00005800| 48 49 6e 56 61 72 73 2e | 69 6e 52 65 66 4e 75 6d |HInVars.|inRefNum| |00005810| 29 3b 0d 09 09 67 73 53 | 48 49 6e 56 61 72 73 2e |);...gsS|HInVars.| |00005820| 72 65 63 6f 72 64 69 6e | 67 20 3d 20 66 61 6c 73 |recordin|g = fals| |00005830| 65 3b 0d 09 09 67 73 53 | 48 49 6e 56 61 72 73 2e |e;...gsS|HInVars.| |00005840| 69 6e 52 65 66 4e 75 6d | 20 3d 20 30 3b 0d 09 09 |inRefNum| = 0;...| |00005850| 69 66 20 28 67 73 53 48 | 49 6e 56 61 72 73 2e 61 |if (gsSH|InVars.a| |00005860| 70 70 43 6f 6d 70 6c 65 | 74 65 20 21 3d 20 6e 69 |ppComple|te != ni| |00005870| 6c 29 0d 09 09 09 2a 67 | 73 53 48 49 6e 56 61 72 |l)....*g|sSHInVar| |00005880| 73 2e 61 70 70 43 6f 6d | 70 6c 65 74 65 20 3d 20 |s.appCom|plete = | |00005890| 74 72 75 65 3b 0d 09 7d | 0d 7d 0d 53 48 49 64 6c |true;..}|.}.SHIdl| |000058a0| 65 20 69 73 20 6f 6e 65 | 20 6f 66 20 74 68 65 20 |e is one| of the | |000058b0| 6d 6f 73 74 20 69 6d 70 | 6f 72 74 61 6e 74 20 72 |most imp|ortant r| |000058c0| 6f 75 74 69 6e 65 73 20 | 69 6e 20 48 65 6c 70 65 |outines |in Helpe| |000058d0| 72 2e 20 49 74 20 70 65 | 72 66 6f 72 6d 73 20 63 |r. It pe|rforms c| |000058e0| 6c 65 61 6e 75 70 20 6f | 66 20 63 6f 6d 70 6c 65 |leanup o|f comple| |000058f0| 74 65 64 20 73 6f 75 6e | 64 20 70 6c 61 79 62 61 |ted soun|d playba| |00005900| 63 6b 20 61 6e 64 20 72 | 65 63 6f 72 64 69 6e 67 |ck and r|ecording| |00005910| 2e 20 46 69 72 73 74 20 | 53 48 49 64 6c 65 20 63 |. First |SHIdle c| |00005920| 6c 65 61 72 73 20 74 68 | 65 20 61 70 70 6c 69 63 |lears th|e applic| |00005930| 61 74 69 6f 6e d5 73 20 | 61 74 74 65 6e 74 69 6f |ation.s |attentio| |00005940| 6e 20 66 6c 61 67 2e 20 | 46 6f 72 20 70 6c 61 79 |n flag. |For play| |00005950| 62 61 63 6b 20 63 6c 65 | 61 6e 75 70 2c 20 69 74 |back cle|anup, it| |00005960| 20 69 74 65 72 61 74 65 | 73 20 74 68 72 6f 75 67 | iterate|s throug| |00005970| 68 20 74 68 65 20 6f 75 | 74 70 75 74 20 72 65 63 |h the ou|tput rec| |00005980| 6f 72 64 73 20 6c 6f 6f | 6b 69 6e 67 20 66 6f 72 |ords loo|king for| |00005990| 20 72 65 63 6f 72 64 73 | 20 74 68 61 74 20 68 61 | records| that ha| |000059a0| 76 65 20 74 68 65 69 72 | 20 69 6e 55 73 65 20 66 |ve their| inUse f| |000059b0| 6c 61 67 20 73 65 74 20 | 61 6e 64 20 68 61 76 65 |lag set |and have| |000059c0| 20 6b 53 48 43 6f 6d 70 | 6c 65 74 65 20 69 6e 20 | kSHComp|lete in | |000059d0| 74 68 65 69 72 20 73 6f | 75 6e 64 20 63 68 61 6e |their so|und chan| |000059e0| 6e 65 6c d5 73 20 75 73 | 65 72 49 6e 66 6f 20 66 |nel.s us|erInfo f| |000059f0| 69 65 6c 64 2e 20 54 68 | 65 73 65 20 73 6f 75 6e |ield. Th|ese soun| |00005a00| 64 73 20 68 61 76 65 20 | 62 65 65 6e 20 66 6c 61 |ds have |been fla| |00005a10| 67 67 65 64 20 61 73 20 | 63 6f 6d 70 6c 65 74 65 |gged as |complete| |00005a20| 64 20 62 79 20 74 68 65 | 20 63 61 6c 6c 62 61 63 |d by the| callbac| |00005a30| 6b 20 72 6f 75 74 69 6e | 65 2e 20 57 68 65 6e 20 |k routin|e. When | |00005a40| 73 75 63 68 20 61 6e 20 | 6f 75 74 70 75 74 20 72 |such an |output r| |00005a50| 65 63 6f 72 64 20 69 73 | 20 66 6f 75 6e 64 2c 20 |ecord is| found, | |00005a60| 69 74 73 20 63 68 61 6e | 6e 65 6c 20 69 73 20 63 |its chan|nel is c| |00005a70| 6c 6f 73 65 64 20 77 69 | 74 68 20 61 20 63 61 6c |losed wi|th a cal| |00005a80| 6c 20 74 6f 20 53 48 52 | 65 6c 65 61 73 65 4f 75 |l to SHR|eleaseOu| |00005a90| 74 52 65 63 2e 0d 76 6f | 69 64 20 53 48 52 65 6c |tRec..vo|id SHRel| |00005aa0| 65 61 73 65 4f 75 74 52 | 65 63 28 53 48 4f 75 74 |easeOutR|ec(SHOut| |00005ab0| 50 74 72 20 6f 75 74 52 | 65 63 29 0d 7b 0d 09 73 |Ptr outR|ec).{..s| |00005ac0| 68 6f 72 74 09 69 3b 0d | 09 42 6f 6f 6c 65 61 6e |hort.i;.|.Boolean| |00005ad0| 09 66 6f 75 6e 64 20 3d | 20 66 61 6c 73 65 3b 0d |.found =| false;.| |00005ae0| 09 0d 09 2f 2f 20 41 6e | 20 53 48 4f 75 74 52 65 |...// An| SHOutRe| |00005af0| 63 27 73 20 69 6e 55 73 | 65 20 66 6c 61 67 20 67 |c's inUs|e flag g| |00005b00| 65 74 73 20 73 65 74 20 | 6f 6e 6c 79 20 69 66 20 |ets set |only if | |00005b10| 53 6e 64 4e 65 77 43 68 | 61 6e 6e 65 6c 20 68 61 |SndNewCh|annel ha| |00005b20| 73 20 62 65 65 6e 0d 09 | 2f 2f 20 63 61 6c 6c 65 |s been..|// calle| |00005b30| 64 20 6f 6e 20 74 68 65 | 20 72 65 63 6f 72 64 27 |d on the| record'| |00005b40| 73 20 73 6f 75 6e 64 20 | 63 68 61 6e 6e 65 6c 2e |s sound |channel.| |00005b50| 20 53 6f 20 69 66 20 69 | 74 27 73 20 69 6e 20 75 | So if i|t's in u| |00005b60| 73 65 2c 20 77 65 20 63 | 61 6c 6c 0d 09 2f 2f 20 |se, we c|all..// | |00005b70| 53 6e 64 44 69 73 70 6f | 73 65 43 68 61 6e 6e 65 |SndDispo|seChanne| |00005b80| 6c 20 61 6e 64 20 69 67 | 6e 6f 72 65 20 74 68 65 |l and ig|nore the| |00005b90| 20 65 72 72 6f 72 2e 20 | 28 57 68 61 74 20 65 6c | error. |(What el| |00005ba0| 73 65 20 63 61 6e 20 77 | 65 20 64 6f 3f 29 0d 09 |se can w|e do?)..| |00005bb0| 69 66 20 28 6f 75 74 52 | 65 63 2d 3e 69 6e 55 73 |if (outR|ec->inUs| |00005bc0| 65 29 0d 09 09 53 6e 64 | 44 69 73 70 6f 73 65 43 |e)...Snd|DisposeC| |00005bd0| 68 61 6e 6e 65 6c 28 26 | 6f 75 74 52 65 63 2d 3e |hannel(&|outRec->| |00005be0| 63 68 61 6e 6e 65 6c 2c | 20 6b 53 48 51 75 69 65 |channel,| kSHQuie| |00005bf0| 74 4e 6f 77 29 3b 0d 09 | 2f 2f 20 49 66 20 74 68 |tNow);..|// If th| |00005c00| 69 73 20 73 6f 75 6e 64 | 20 68 61 6e 64 6c 65 20 |is sound| handle | |00005c10| 69 73 6e 27 74 20 62 65 | 69 6e 67 20 75 73 65 64 |isn't be|ing used| |00005c20| 20 62 79 20 73 6f 6d 65 | 20 6f 74 68 65 72 20 6f | by some| other o| |00005c30| 75 74 70 75 74 20 72 65 | 63 6f 72 64 2c 0d 09 2f |utput re|cord,../| |00005c40| 2f 20 6b 69 6e 64 6c 79 | 20 72 65 73 74 6f 72 65 |/ kindly| restore| |00005c50| 20 74 68 65 20 6f 72 69 | 67 69 6e 61 6c 20 68 61 | the ori|ginal ha| |00005c60| 6e 64 6c 65 20 73 74 61 | 74 65 2e 0d 09 69 66 20 |ndle sta|te...if | |00005c70| 28 6f 75 74 52 65 63 2d | 3e 73 6f 75 6e 64 20 21 |(outRec-|>sound !| |00005c80| 3d 20 6e 69 6c 29 20 7b | 0d 09 09 66 6f 72 20 28 |= nil) {|...for (| |00005c90| 69 20 3d 20 30 3b 20 69 | 20 3c 20 67 73 53 48 4f |i = 0; i| < gsSHO| |00005ca0| 75 74 56 61 72 73 2e 6e | 75 6d 4f 75 74 52 65 63 |utVars.n|umOutRec| |00005cb0| 73 20 26 26 20 21 66 6f | 75 6e 64 3b 20 69 2b 2b |s && !fo|und; i++| |00005cc0| 29 0d 09 09 09 69 66 20 | 28 26 67 73 53 48 4f 75 |)....if |(&gsSHOu| |00005cd0| 74 56 61 72 73 2e 6f 75 | 74 41 72 72 61 79 5b 69 |tVars.ou|tArray[i| |00005ce0| 5d 20 21 3d 20 6f 75 74 | 52 65 63 20 26 26 0d 09 |] != out|Rec &&..| |00005cf0| 09 09 09 09 67 73 53 48 | 4f 75 74 56 61 72 73 2e |....gsSH|OutVars.| |00005d00| 6f 75 74 41 72 72 61 79 | 5b 69 5d 2e 69 6e 55 73 |outArray|[i].inUs| |00005d10| 65 20 26 26 0d 09 09 09 | 09 09 67 73 53 48 4f 75 |e &&....|..gsSHOu| |00005d20| 74 56 61 72 73 2e 6f 75 | 74 41 72 72 61 79 5b 69 |tVars.ou|tArray[i| |00005d30| 5d 2e 73 6f 75 6e 64 20 | 3d 3d 20 6f 75 74 52 65 |].sound |== outRe| |00005d40| 63 2d 3e 73 6f 75 6e 64 | 29 0d 09 09 09 09 66 6f |c->sound|).....fo| |00005d50| 75 6e 64 20 3d 20 74 72 | 75 65 3b 0d 09 09 0d 09 |und = tr|ue;.....| |00005d60| 09 69 66 20 28 21 66 6f | 75 6e 64 29 0d 09 09 09 |.if (!fo|und)....| |00005d70| 48 53 65 74 53 74 61 74 | 65 28 6f 75 74 52 65 63 |HSetStat|e(outRec| |00005d80| 2d 3e 73 6f 75 6e 64 2c | 20 6f 75 74 52 65 63 2d |->sound,| outRec-| |00005d90| 3e 68 61 6e 64 6c 65 53 | 74 61 74 65 29 3b 0d 09 |>handleS|tate);..| |00005da0| 7d 0d 09 0d 09 6f 75 74 | 52 65 63 2d 3e 69 6e 55 |}....out|Rec->inU| |00005db0| 73 65 20 3d 20 66 61 6c | 73 65 3b 0d 7d 0d 54 68 |se = fal|se;.}.Th| |00005dc0| 65 20 53 48 52 65 6c 65 | 61 73 65 4f 75 74 52 65 |e SHRele|aseOutRe| |00005dd0| 63 20 72 6f 75 74 69 6e | 65 20 68 61 73 20 74 77 |c routin|e has tw| |00005de0| 6f 20 69 6d 70 6f 72 74 | 61 6e 74 20 66 75 6e 63 |o import|ant func| |00005df0| 74 69 6f 6e 73 2e 20 46 | 69 72 73 74 2c 20 69 74 |tions. F|irst, it| |00005e00| 20 63 61 6c 6c 73 20 53 | 6e 64 44 69 73 70 6f 73 | calls S|ndDispos| |00005e10| 65 43 68 61 6e 6e 65 6c | 20 74 6f 20 66 72 65 65 |eChannel| to free| |00005e20| 20 75 70 20 74 68 65 20 | 73 6f 75 6e 64 20 63 68 | up the |sound ch| |00005e30| 61 6e 6e 65 6c 2e 20 53 | 65 63 6f 6e 64 2c 20 69 |annel. S|econd, i| |00005e40| 74 20 72 65 73 74 6f 72 | 65 73 20 74 68 65 20 68 |t restor|es the h| |00005e50| 61 6e 64 6c 65 20 73 74 | 61 74 65 0d 6f 66 20 74 |andle st|ate.of t| |00005e60| 68 65 20 73 6f 75 6e 64 | 20 74 68 61 74 20 77 61 |he sound| that wa| |00005e70| 73 20 70 6c 61 79 69 6e | 67 20 69 66 20 74 68 61 |s playin|g if tha| |00005e80| 74 20 73 61 6d 65 20 73 | 6f 75 6e 64 20 69 73 6e |t same s|ound isn| |00005e90| d5 74 20 63 75 72 72 65 | 6e 74 6c 79 20 70 6c 61 |.t curre|ntly pla| |00005ea0| 79 69 6e 67 20 6f 6e 20 | 73 6f 6d 65 20 6f 74 68 |ying on |some oth| |00005eb0| 65 72 20 63 68 61 6e 6e | 65 6c 2e 0d 52 65 63 6f |er chann|el..Reco| |00005ec0| 72 64 69 6e 67 20 63 6c | 65 61 6e 75 70 20 69 73 |rding cl|eanup is| |00005ed0| 20 61 6c 73 6f 20 70 65 | 72 66 6f 72 6d 65 64 20 | also pe|rformed | |00005ee0| 62 61 63 6b 20 69 6e 20 | 53 48 49 64 6c 65 2e 20 |back in |SHIdle. | |00005ef0| 49 66 20 74 68 65 20 72 | 65 63 6f 72 64 69 6e 67 |If the r|ecording| |00005f00| 20 66 6c 61 67 20 61 6e | 64 20 74 68 65 20 72 65 | flag an|d the re| |00005f10| 63 6f 72 64 43 6f 6d 70 | 6c 65 74 65 20 66 6c 61 |cordComp|lete fla| |00005f20| 67 20 61 72 65 20 73 65 | 74 2c 20 74 68 65 20 72 |g are se|t, the r| |00005f30| 65 63 6f 72 64 20 63 61 | 6c 6c 62 61 63 6b 20 68 |ecord ca|llback h| |00005f40| 61 73 20 69 6e 66 6f 72 | 6d 65 64 20 48 65 6c 70 |as infor|med Help| |00005f50| 65 72 20 74 68 61 74 20 | 72 65 63 6f 72 64 69 6e |er that |recordin| |00005f60| 67 20 69 73 20 63 6f 6d | 70 6c 65 74 65 2e 20 52 |g is com|plete. R| |00005f70| 69 67 68 74 20 61 77 61 | 79 2c 20 48 65 6c 70 65 |ight awa|y, Helpe| |00005f80| 72 20 75 6e 6c 6f 63 6b | 73 20 74 68 65 20 73 6f |r unlock|s the so| |00005f90| 75 6e 64 20 68 61 6e 64 | 6c 65 2e 20 4e 65 78 74 |und hand|le. Next| |00005fa0| 20 48 65 6c 70 65 72 20 | 63 68 65 63 6b 73 20 66 | Helper |checks f| |00005fb0| 6f 72 20 65 72 72 6f 72 | 73 2e 20 49 66 20 74 68 |or error|s. If th| |00005fc0| 65 20 61 70 70 6c 69 63 | 61 74 69 6f 6e 20 63 61 |e applic|ation ca| |00005fd0| 6c 6c 65 64 20 53 48 52 | 65 63 6f 72 64 53 74 6f |lled SHR|ecordSto| |00005fe0| 70 20 74 6f 20 6d 61 6e | 75 61 6c 6c 79 20 73 74 |p to man|ually st| |00005ff0| 6f 70 20 72 65 63 6f 72 | 64 69 6e 67 20 62 65 66 |op recor|ding bef| |00006000| 6f 72 65 20 74 68 65 20 | 62 75 66 66 65 72 20 77 |ore the |buffer w| |00006010| 61 73 20 66 75 6c 6c 2c | 20 74 68 65 20 65 72 72 |as full,| the err| |00006020| 6f 72 20 61 62 6f 72 74 | 45 72 72 20 69 73 20 67 |or abort|Err is g| |00006030| 65 6e 65 72 61 74 65 64 | 2e 20 57 65 20 64 6f 6e |enerated|. We don| |00006040| d5 74 20 72 65 61 6c 6c | 79 20 63 6f 6e 73 69 64 |.t reall|y consid| |00006050| 65 72 20 74 68 69 73 20 | 61 6e 20 65 72 72 6f 72 |er this |an error| |00006060| 2c 20 73 6f 20 77 65 20 | 65 78 70 72 65 73 73 6c |, so we |expressl| |00006070| 79 20 61 6c 6c 6f 77 20 | 61 62 6f 72 74 45 72 72 |y allow |abortErr| |00006080| 2e 20 49 66 20 61 6e 20 | 65 72 72 6f 72 20 64 69 |. If an |error di| |00006090| 64 20 6f 63 63 75 72 2c | 20 48 65 6c 70 65 72 20 |d occur,| Helper | |000060a0| 73 61 76 65 73 20 74 68 | 65 20 65 72 72 6f 72 20 |saves th|e error | |000060b0| 63 6f 64 65 2e 20 54 68 | 69 73 20 77 61 79 2c 20 |code. Th|is way, | |000060c0| 6c 61 74 65 72 2c 20 77 | 68 65 6e 20 74 68 65 20 |later, w|hen the | |000060d0| 61 70 70 6c 69 63 61 74 | 69 6f 6e 20 63 61 6c 6c |applicat|ion call| |000060e0| 73 20 53 48 47 65 74 52 | 65 63 6f 72 64 65 64 53 |s SHGetR|ecordedS| |000060f0| 6f 75 6e 64 2c 20 48 65 | 6c 70 65 72 20 63 61 6e |ound, He|lper can| |00006100| 20 72 65 74 75 72 6e 20 | 61 6e 20 61 70 70 72 6f | return |an appro| |00006110| 70 72 69 61 74 65 20 4f | 53 45 72 72 2e 20 49 66 |priate O|SErr. If| |00006120| 20 6e 6f 20 65 72 72 6f | 72 20 6f 63 63 75 72 72 | no erro|r occurr| |00006130| 65 64 2c 20 48 65 6c 70 | 65 72 20 63 61 6c 63 75 |ed, Help|er calcu| |00006140| 6c 61 74 65 73 20 74 68 | 65 20 61 63 74 75 61 6c |lates th|e actual| |00006150| 20 73 69 7a 65 20 6f 66 | 20 74 68 65 20 73 61 6d | size of| the sam| |00006160| 70 6c 65 64 20 73 6f 75 | 6e 64 20 61 6e 64 20 62 |pled sou|nd and b| |00006170| 75 69 6c 64 73 20 61 6e | 20 61 70 70 72 6f 70 72 |uilds an| appropr| |00006180| 69 61 74 65 20 73 6f 75 | 6e 64 20 68 65 61 64 65 |iate sou|nd heade| |00006190| 72 2c 20 69 6e 63 6c 75 | 64 69 6e 67 20 74 68 65 |r, inclu|ding the| |000061a0| 20 63 6f 72 72 65 63 74 | 20 6c 65 6e 67 74 68 2e | correct| length.| |000061b0| 20 0d 41 66 74 65 72 20 | 63 68 65 63 6b 69 6e 67 | .After |checking| |000061c0| 20 66 6f 72 20 65 72 72 | 6f 72 73 2c 20 48 65 6c | for err|ors, Hel| |000061d0| 70 65 72 20 72 65 73 69 | 7a 65 73 20 74 68 65 20 |per resi|zes the | |000061e0| 68 61 6e 64 6c 65 20 74 | 6f 20 65 78 61 63 74 6c |handle t|o exactl| |000061f0| 79 20 74 68 65 20 73 69 | 7a 65 20 69 74 20 73 68 |y the si|ze it sh| |00006200| 6f 75 6c 64 20 62 65 2e | 20 54 68 65 6e 20 69 74 |ould be.| Then it| |00006210| 20 63 61 6c 6c 73 20 53 | 50 42 43 6c 6f 73 65 44 | calls S|PBCloseD| |00006220| 65 76 69 63 65 20 74 6f | 20 63 6c 6f 73 65 20 74 |evice to| close t| |00006230| 68 65 20 73 6f 75 6e 64 | 20 69 6e 70 75 74 20 64 |he sound| input d| |00006240| 65 76 69 63 65 2c 20 63 | 6c 65 61 72 73 20 74 68 |evice, c|lears th| |00006250| 65 20 72 65 63 6f 72 64 | 69 6e 67 20 66 6c 61 67 |e record|ing flag| |00006260| 2c 20 61 6e 64 20 73 65 | 74 73 20 74 68 65 20 61 |, and se|ts the a| |00006270| 70 70 6c 69 63 61 74 69 | 6f 6e d5 73 20 72 65 63 |pplicati|on.s rec| |00006280| 6f 72 64 69 6e 67 2d 63 | 6f 6d 70 6c 65 74 65 64 |ording-c|ompleted| |00006290| 20 66 6c 61 67 2c 20 69 | 66 20 6f 6e 65 20 77 61 | flag, i|f one wa| |000062a0| 73 20 70 72 6f 76 69 64 | 65 64 2e 0d 41 73 20 79 |s provid|ed..As y| |000062b0| 6f 75 20 63 61 6e 20 73 | 65 65 2c 20 69 74 d5 73 |ou can s|ee, it.s| |000062c0| 20 69 6d 70 6f 72 74 61 | 6e 74 20 74 6f 20 63 61 | importa|nt to ca| |000062d0| 6c 6c 20 53 48 49 64 6c | 65 20 77 68 65 6e 20 74 |ll SHIdl|e when t| |000062e0| 68 65 20 61 74 74 65 6e | 74 69 6f 6e 20 66 6c 61 |he atten|tion fla| |000062f0| 67 20 67 6f 65 73 20 74 | 72 75 65 3b 20 6f 74 68 |g goes t|rue; oth| |00006300| 65 72 77 69 73 65 20 73 | 75 62 73 65 71 75 65 6e |erwise s|ubsequen| |00006310| 74 20 72 65 71 75 65 73 | 74 73 20 66 6f 72 20 70 |t reques|ts for p| |00006320| 6c 61 79 62 61 63 6b 20 | 6f 72 20 72 65 63 6f 72 |layback |or recor| |00006330| 64 69 6e 67 20 6d 61 79 | 20 66 61 69 6c 2e 0d 45 |ding may| fail..E| |00006340| 41 53 59 20 50 4c 41 59 | 42 41 43 4b 20 52 4f 55 |ASY PLAY|BACK ROU| |00006350| 54 49 4e 45 53 0d 4e 6f | 77 20 77 65 d5 6c 6c 20 |TINES.No|w we.ll | |00006360| 6c 6f 6f 6b 20 6d 6f 72 | 65 20 63 6c 6f 73 65 6c |look mor|e closel| |00006370| 79 20 61 74 20 48 65 6c | 70 65 72 d5 73 20 65 61 |y at Hel|per.s ea| |00006380| 73 79 20 70 6c 61 79 62 | 61 63 6b 20 72 6f 75 74 |sy playb|ack rout| |00006390| 69 6e 65 73 2c 20 53 48 | 50 6c 61 79 42 79 49 44 |ines, SH|PlayByID| |000063a0| 2c 20 53 48 50 6c 61 79 | 42 79 48 61 6e 64 6c 65 |, SHPlay|ByHandle| |000063b0| 2c 20 53 48 50 6c 61 79 | 53 74 6f 70 2c 20 61 6e |, SHPlay|Stop, an| |000063c0| 64 20 53 48 50 6c 61 79 | 53 74 6f 70 41 6c 6c 2e |d SHPlay|StopAll.| |000063d0| 0d 53 48 50 4c 41 59 42 | 59 49 44 20 41 4e 44 20 |.SHPLAYB|YID AND | |000063e0| 53 48 50 4c 41 59 42 59 | 48 41 4e 44 4c 45 0d 70 |SHPLAYBY|HANDLE.p| |000063f0| 61 73 63 61 6c 20 4f 53 | 45 72 72 20 53 48 50 6c |ascal OS|Err SHPl| +--------+-------------------------+-------------------------+--------+--------+ Only 25.0 KB of data is shown above.